# HG changeset patch # User Sebastien Jodogne # Date 1571166669 -7200 # Node ID 5d1b0d2f4b155d3ae9f084c1a1715ff25a4fb174 # Parent 04a95ee913275636089a3c8369940ad0250d5c4f fix diff -r 04a95ee91327 -r 5d1b0d2f4b15 Applications/Generic/NativeStoneApplicationContext.cpp --- 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 widget) { that_.centralViewport_.SetCentralWidget(widget); - return *widget; } diff -r 04a95ee91327 -r 5d1b0d2f4b15 Applications/Generic/NativeStoneApplicationContext.h --- 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 widget); Deprecated::IViewport& GetCentralViewport() { diff -r 04a95ee91327 -r 5d1b0d2f4b15 Applications/IStoneApplication.h --- 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 widget) = 0; + + virtual boost::shared_ptr GetCentralWidget() = 0; + virtual void Finalize() = 0; }; } diff -r 04a95ee91327 -r 5d1b0d2f4b15 Applications/Samples/SampleApplicationBase.h --- 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 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 widget) ORTHANC_OVERRIDE + { + mainWidget_ = widget; + } + + virtual boost::shared_ptr 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 diff -r 04a95ee91327 -r 5d1b0d2f4b15 Applications/Samples/SingleFrameApplication.h --- 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(); widget_.reset(new Deprecated::SliceViewerWidget("main-widget")); - mainWidget_ = widget_.get(); // TODO - awful + SetCentralWidget(widget_); boost::shared_ptr layer(new Deprecated::DicomSeriesVolumeSlicer); layer->Connect(context->GetOrthancApiClient()); diff -r 04a95ee91327 -r 5d1b0d2f4b15 Framework/Deprecated/Viewport/WidgetViewport.cpp --- 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 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; } diff -r 04a95ee91327 -r 5d1b0d2f4b15 Framework/Deprecated/Viewport/WidgetViewport.h --- 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 centralWidget_; + boost::shared_ptr centralWidget_; IStatusBar* statusBar_; std::auto_ptr mouseTracker_; bool isMouseOver_; @@ -47,7 +47,7 @@ virtual void SetStatusBar(IStatusBar& statusBar); - IWidget& SetCentralWidget(IWidget* widget); // Takes ownership + void SetCentralWidget(boost::shared_ptr widget); virtual void NotifyBackgroundChanged();