# HG changeset patch # User Sebastien Jodogne # Date 1791555141 -7200 # Node ID badae7b22831d09316a2f5a2b9798e7ff4f2e55b # Parent 29020ee1e0206f5bdd55690c305c969cf68d1f43 cont diff -r 29020ee1e020 -r badae7b22831 OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.cpp --- a/OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.cpp Fri Oct 09 16:09:48 2026 +0200 +++ b/OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.cpp Fri Oct 09 16:12:21 2026 +0200 @@ -48,19 +48,16 @@ ScenePoint2D originalClickPosition_; AngleMeasureTool::AngleHighlightArea modifiedZone_; bool alive_; - boost::weak_ptr& viewport_; // TODO Refactoring boost::shared_ptr editCommand_; public: Tracker(const boost::shared_ptr& tool, bool isCreation, const Scene2D& scene, - const PointerEvent& e, - boost::weak_ptr& viewport) : + const PointerEvent& e) : tool_(tool), originalClickPosition_(e.GetMainPosition().Apply(scene.GetCanvasToSceneTransform())), - alive_(true), - viewport_(viewport) + alive_(true) { if (!tool) { @@ -70,20 +67,15 @@ modifiedZone_ = tool_->AngleHitTest(scene, originalClickPosition_); originalMemento_.reset(dynamic_cast(tool->CreateMemento())); - boost::shared_ptr sharedViewport = viewport.lock(); - if (sharedViewport) + if (isCreation) { - std::unique_ptr lock(sharedViewport->Lock()); - if (isCreation) - { - boost::shared_ptr command(new CreateMeasureCommand(tool_)); - lock->GetController().PushCommand(command); - } - else - { - boost::shared_ptr command(new EditMeasureCommand(tool_)); - editCommand_ = command; - } + boost::shared_ptr command(new CreateMeasureCommand(tool_)); + tool->GetController().PushCommand(command); + } + else + { + boost::shared_ptr command(new EditMeasureCommand(tool_)); + editCommand_ = command; } } @@ -143,13 +135,8 @@ if (alive_ && editCommand_) { editCommand_->SetMementoModified(tool_->CreateMemento()); - - boost::shared_ptr sharedViewport = viewport_.lock(); - if (sharedViewport) - { - std::unique_ptr lock(sharedViewport->Lock()); - lock->GetController().PushCommand(editCommand_); - } + tool_->GetController().PushCommand(editCommand_); + editCommand_.reset(); } alive_ = false; @@ -354,7 +341,7 @@ } else { - return new Tracker(boost::dynamic_pointer_cast(shared_from_this()), isCreation, scene, e, viewport_); + return new Tracker(boost::dynamic_pointer_cast(shared_from_this()), isCreation, scene, e); } }