changeset 1069:5d1b0d2f4b15 broker

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 15 Oct 2019 21:11:09 +0200
parents 04a95ee91327
children d7887f88710f
files Applications/Generic/NativeStoneApplicationContext.cpp Applications/Generic/NativeStoneApplicationContext.h Applications/IStoneApplication.h Applications/Samples/SampleApplicationBase.h Applications/Samples/SingleFrameApplication.h Framework/Deprecated/Viewport/WidgetViewport.cpp Framework/Deprecated/Viewport/WidgetViewport.h
diffstat 7 files changed, 25 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Generic/NativeStoneApplicationContext.cpp	Tue Oct 15 19:36:57 2019 +0200
+++ b/Applications/Generic/NativeStoneApplicationContext.cpp	Tue Oct 15 21:11:09 2019 +0200
@@ -24,10 +24,10 @@
 
 namespace OrthancStone
 {
-  Deprecated::IWidget& NativeStoneApplicationContext::GlobalMutexLocker::SetCentralWidget(Deprecated::IWidget* widget)
+  void NativeStoneApplicationContext::GlobalMutexLocker::SetCentralWidget(
+    boost::shared_ptr<Deprecated::IWidget> widget)
   {
     that_.centralViewport_.SetCentralWidget(widget);
-    return *widget;
   }
 
 
--- a/Applications/Generic/NativeStoneApplicationContext.h	Tue Oct 15 19:36:57 2019 +0200
+++ b/Applications/Generic/NativeStoneApplicationContext.h	Tue Oct 15 21:11:09 2019 +0200
@@ -56,7 +56,7 @@
       {
       }
 
-      Deprecated::IWidget& SetCentralWidget(Deprecated::IWidget* widget);   // Takes ownership
+      void SetCentralWidget(boost::shared_ptr<Deprecated::IWidget> widget);
 
       Deprecated::IViewport& GetCentralViewport() 
       {
--- a/Applications/IStoneApplication.h	Tue Oct 15 19:36:57 2019 +0200
+++ b/Applications/IStoneApplication.h	Tue Oct 15 21:11:09 2019 +0200
@@ -64,7 +64,11 @@
 #endif
 
     virtual std::string GetTitle() const = 0;
-    virtual Deprecated::IWidget* GetCentralWidget() = 0;
+    
+    virtual void SetCentralWidget(boost::shared_ptr<Deprecated::IWidget> widget) = 0;
+    
+    virtual boost::shared_ptr<Deprecated::IWidget> GetCentralWidget() = 0;
+    
     virtual void Finalize() = 0;
   };
 }
--- a/Applications/Samples/SampleApplicationBase.h	Tue Oct 15 19:36:57 2019 +0200
+++ b/Applications/Samples/SampleApplicationBase.h	Tue Oct 15 21:11:09 2019 +0200
@@ -40,9 +40,8 @@
   {
     class SampleApplicationBase : public IStoneApplication
     {
-    protected:
-      // ownership is transferred to the application context
-      Deprecated::WorldSceneWidget*  mainWidget_;
+    private:
+      boost::shared_ptr<Deprecated::IWidget>  mainWidget_;
 
     public:
       virtual void Initialize(StoneApplicationContext* context,
@@ -64,7 +63,16 @@
 
 
       virtual void Finalize() ORTHANC_OVERRIDE {}
-      virtual Deprecated::IWidget* GetCentralWidget() ORTHANC_OVERRIDE {return mainWidget_;}
+
+      virtual void SetCentralWidget(boost::shared_ptr<Deprecated::IWidget> widget) ORTHANC_OVERRIDE
+      {
+        mainWidget_ = widget;
+      }
+
+      virtual boost::shared_ptr<Deprecated::IWidget> GetCentralWidget() ORTHANC_OVERRIDE
+      {
+        return mainWidget_;
+      }
 
 #if ORTHANC_ENABLE_WASM==1
       // default implementations for a single canvas named "canvas" in the HTML and an emtpy WasmApplicationAdapter
--- a/Applications/Samples/SingleFrameApplication.h	Tue Oct 15 19:36:57 2019 +0200
+++ b/Applications/Samples/SingleFrameApplication.h	Tue Oct 15 21:11:09 2019 +0200
@@ -238,7 +238,7 @@
         int frame = parameters["frame"].as<unsigned int>();
 
         widget_.reset(new Deprecated::SliceViewerWidget("main-widget"));
-        mainWidget_ = widget_.get();  // TODO - awful
+        SetCentralWidget(widget_);
 
         boost::shared_ptr<Deprecated::DicomSeriesVolumeSlicer> layer(new Deprecated::DicomSeriesVolumeSlicer);
         layer->Connect(context->GetOrthancApiClient());
--- a/Framework/Deprecated/Viewport/WidgetViewport.cpp	Tue Oct 15 19:36:57 2019 +0200
+++ b/Framework/Deprecated/Viewport/WidgetViewport.cpp	Tue Oct 15 21:11:09 2019 +0200
@@ -56,7 +56,7 @@
   }
 
 
-  IWidget& WidgetViewport::SetCentralWidget(IWidget* widget)
+  void WidgetViewport::SetCentralWidget(boost::shared_ptr<IWidget> widget)
   {
     if (widget == NULL)
     {
@@ -65,7 +65,7 @@
 
     mouseTracker_.reset(NULL);
 
-    centralWidget_.reset(widget);
+    centralWidget_ = widget;
     centralWidget_->SetViewport(*this);
 
     if (statusBar_ != NULL)
@@ -74,8 +74,6 @@
     }
 
     NotifyBackgroundChanged();
-
-    return *widget;
   }
 
 
--- a/Framework/Deprecated/Viewport/WidgetViewport.h	Tue Oct 15 19:36:57 2019 +0200
+++ b/Framework/Deprecated/Viewport/WidgetViewport.h	Tue Oct 15 21:11:09 2019 +0200
@@ -31,7 +31,7 @@
   class WidgetViewport : public IViewport
   {
   private:
-    std::auto_ptr<IWidget>        centralWidget_;
+    boost::shared_ptr<IWidget>    centralWidget_;
     IStatusBar*                   statusBar_;
     std::auto_ptr<IMouseTracker>  mouseTracker_;
     bool                          isMouseOver_;
@@ -47,7 +47,7 @@
 
     virtual void SetStatusBar(IStatusBar& statusBar);
 
-    IWidget& SetCentralWidget(IWidget* widget);  // Takes ownership
+    void SetCentralWidget(boost::shared_ptr<IWidget> widget);
 
     virtual void NotifyBackgroundChanged();