diff OrthancStone/Sources/Volumes/VolumeSceneLayerSource.h @ 1606:874e178f34e9

- ViewportController now has weak ptr to Viewport - Measuring tools + related commands and all trackers now store only a weak_ptr to the Viewport and lock() on demand for usage - LayerHolder and FixedPoint aligner store only a weak_ptr to the Viewport, too - Fixed float/double warning in GrayscaleWindowingSceneTracker
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 28 Oct 2020 20:14:34 +0100
parents 8563ea5d8ae4
children 52b8b96cb55f
line wrap: on
line diff
--- a/OrthancStone/Sources/Volumes/VolumeSceneLayerSource.h	Wed Oct 28 20:06:55 2020 +0100
+++ b/OrthancStone/Sources/Volumes/VolumeSceneLayerSource.h	Wed Oct 28 20:14:34 2020 +0100
@@ -23,6 +23,7 @@
 #pragma once
 
 #include "../Scene2D/Scene2D.h"
+#include "../Viewport/IViewport.h"
 #include "IVolumeSlicer.h"
 
 #include <boost/shared_ptr.hpp>
@@ -40,7 +41,7 @@
   class VolumeSceneLayerSource : public boost::noncopyable
   {
   private:
-    boost::shared_ptr<OrthancStone::IViewport>  viewport_;
+    boost::weak_ptr<OrthancStone::IViewport>  viewport_;
     int                                       layerDepth_;
     boost::shared_ptr<IVolumeSlicer>          slicer_;
     std::unique_ptr<ILayerStyleConfigurator>  configurator_;
@@ -50,8 +51,15 @@
 
     void ClearLayer();
 
+    /**
+    This will return a scoped lock to the viewport.
+    If the viewport does not exist anymore, then nullptr is returned.
+    */
+    IViewport::ILock* GetViewportLock();
+    IViewport::ILock* GetViewportLock() const;
+
   public:
-    VolumeSceneLayerSource(boost::shared_ptr<OrthancStone::IViewport>  viewport,
+    VolumeSceneLayerSource(boost::weak_ptr<OrthancStone::IViewport>  viewport,
                            int layerDepth,
                            const boost::shared_ptr<IVolumeSlicer>& slicer);