Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2DViewport/LayerHolder.cpp @ 1685:7896aac14587
Protected against usage of dying viewport
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 25 Nov 2020 12:16:53 +0100 |
parents | 646e581e115b |
children | 9ac2a65d4172 |
comparison
equal
deleted
inserted
replaced
1684:fb62c1522193 | 1685:7896aac14587 |
---|---|
94 } | 94 } |
95 | 95 |
96 void LayerHolder::DeleteLayers() | 96 void LayerHolder::DeleteLayers() |
97 { | 97 { |
98 std::unique_ptr<IViewport::ILock> lock(GetViewportLock()); | 98 std::unique_ptr<IViewport::ILock> lock(GetViewportLock()); |
99 Scene2D& scene = lock->GetController().GetScene(); | 99 if (lock) |
100 { | |
101 Scene2D& scene = lock->GetController().GetScene(); | |
100 | 102 |
101 for (int i = 0; i < textLayerCount_ + polylineLayerCount_; ++i) | 103 for (int i = 0; i < textLayerCount_ + polylineLayerCount_; ++i) |
102 { | 104 { |
103 ORTHANC_ASSERT(scene.HasLayer(baseLayerIndex_ + i), "No layer"); | 105 ORTHANC_ASSERT(scene.HasLayer(baseLayerIndex_ + i), "No layer"); |
104 scene.DeleteLayer(baseLayerIndex_ + i); | 106 scene.DeleteLayer(baseLayerIndex_ + i); |
107 } | |
108 baseLayerIndex_ = -1; | |
109 lock->Invalidate(); | |
105 } | 110 } |
106 baseLayerIndex_ = -1; | |
107 lock->Invalidate(); | |
108 } | 111 } |
109 | 112 |
110 PolylineSceneLayer* LayerHolder::GetPolylineLayer(int index /*= 0*/) | 113 PolylineSceneLayer* LayerHolder::GetPolylineLayer(int index /*= 0*/) |
111 { | 114 { |
112 std::unique_ptr<IViewport::ILock> lock(GetViewportLock()); | 115 std::unique_ptr<IViewport::ILock> lock(GetViewportLock()); |