diff Applications/Samples/Common/RtViewerView.h @ 1619:4c9e68291467

Added code to remove the wheel callback in dtor, to prevent access to dead object
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 02 Nov 2020 17:55:35 +0100
parents 32e0c007789d
children 52b8b96cb55f
line wrap: on
line diff
--- a/Applications/Samples/Common/RtViewerView.h	Mon Nov 02 17:54:18 2020 +0100
+++ b/Applications/Samples/Common/RtViewerView.h	Mon Nov 02 17:55:35 2020 +0100
@@ -52,12 +52,18 @@
       , currentPlane_(0)
       , projection_(projection)
       , ctLayer_(0)
+      , canvasId_(canvasId)
     {
       viewport_ = CreateViewport(canvasId);
       FLOATING_INFOTEXT_LAYER_ZINDEX = 6;
       FIXED_INFOTEXT_LAYER_ZINDEX = 7;
     }
 
+    ~RtViewerView()
+    {
+      CleanupViewportEvents();
+    }
+
     /**
     This method is called when the scene transform changes. It allows to
     recompute the visual elements whose content depend upon the scene transform
@@ -112,6 +118,7 @@
                                const std::string& value);
     boost::shared_ptr<RtViewerApp> GetApp();
     boost::shared_ptr<IViewport> CreateViewport(const std::string& canvasId);
+    void CleanupViewportEvents();
     void DisplayInfoText();
     void HideInfoText();
     void DisplayFloatingCtrlInfoText(const PointerEvent& e);
@@ -141,5 +148,6 @@
     boost::shared_ptr<IViewport> viewport_;
 
     int ctLayer_;
+    std::string canvasId_;
   };
 }