Skip to content

Commit 0eaba81

Browse files
authoredApr 4, 2020
[BUG][3D] fix 3D crash with measure line (#35412)
* fix 3D crash with measure line * avoid non wanted windows opening of identify tool and measurment tool * adds guard avoid crashing when closing settings * spelling
1 parent 3c643d9 commit 0eaba81

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed
 

‎src/app/3d/qgs3dmaptoolidentify.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void Qgs3DMapToolIdentify::activate()
8787
}
8888

8989
mCanvas->scene()->registerPickHandler( mPickHandler.get() );
90+
mIsActive = true;
9091
}
9192

9293
void Qgs3DMapToolIdentify::deactivate()
@@ -97,6 +98,7 @@ void Qgs3DMapToolIdentify::deactivate()
9798
}
9899

99100
mCanvas->scene()->unregisterPickHandler( mPickHandler.get() );
101+
mIsActive = false;
100102
}
101103

102104
QCursor Qgs3DMapToolIdentify::cursor() const
@@ -106,6 +108,8 @@ QCursor Qgs3DMapToolIdentify::cursor() const
106108

107109
void Qgs3DMapToolIdentify::onMapSettingsChanged()
108110
{
111+
if ( !mIsActive )
112+
return;
109113
connect( mCanvas->scene(), &Qgs3DMapScene::terrainEntityChanged, this, &Qgs3DMapToolIdentify::onTerrainEntityChanged );
110114
}
111115

@@ -153,6 +157,8 @@ void Qgs3DMapToolIdentify::onTerrainPicked( Qt3DRender::QPickEvent *event )
153157

154158
void Qgs3DMapToolIdentify::onTerrainEntityChanged()
155159
{
160+
if ( !mIsActive )
161+
return;
156162
// no need to disconnect from the previous entity: it has been destroyed
157163
// start listening to the new terrain entity
158164
if ( QgsTerrainEntity *terrainEntity = mCanvas->scene()->terrainEntity() )

‎src/app/3d/qgs3dmaptoolidentify.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class Qgs3DMapToolIdentify : public Qgs3DMapTool
5353
private:
5454
std::unique_ptr<Qgs3DMapToolIdentifyPickHandler> mPickHandler;
5555

56+
bool mIsActive = false;
57+
5658
friend class Qgs3DMapToolIdentifyPickHandler;
5759
};
5860

‎src/app/3d/qgs3dmaptoolmeasureline.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ QCursor Qgs3DMapToolMeasureLine::cursor() const
124124

125125
void Qgs3DMapToolMeasureLine::onMapSettingsChanged()
126126
{
127+
if ( !mIsAlreadyActivated )
128+
return;
127129
connect( mCanvas->scene(), &Qgs3DMapScene::terrainEntityChanged, this, &Qgs3DMapToolMeasureLine::onTerrainEntityChanged );
128130

129131
// Update scale if the terrain vertical scale changed
@@ -137,6 +139,8 @@ void Qgs3DMapToolMeasureLine::onTerrainPicked( Qt3DRender::QPickEvent *event )
137139

138140
void Qgs3DMapToolMeasureLine::onTerrainEntityChanged()
139141
{
142+
if ( !mIsAlreadyActivated )
143+
return;
140144
// no need to disconnect from the previous entity: it has been destroyed
141145
// start listening to the new terrain entity
142146
if ( QgsTerrainEntity *terrainEntity = mCanvas->scene()->terrainEntity() )
@@ -175,6 +179,8 @@ void Qgs3DMapToolMeasureLine::handleClick( Qt3DRender::QPickEvent *event, const
175179

176180
void Qgs3DMapToolMeasureLine::updateMeasurementLayer()
177181
{
182+
if ( !mMeasurementLayer )
183+
return;
178184
double verticalScale = canvas()->map()->terrainVerticalScale();
179185
QgsLineString *line;
180186
if ( verticalScale != 1.0 )
@@ -205,6 +211,8 @@ void Qgs3DMapToolMeasureLine::updateMeasurementLayer()
205211

206212
void Qgs3DMapToolMeasureLine::updateSettings()
207213
{
214+
if ( !mMeasurementLayer )
215+
return;
208216
// Line style
209217
QgsLine3DSymbol *lineSymbol = new QgsLine3DSymbol;
210218
lineSymbol->setRenderAsSimpleLines( true );

0 commit comments

Comments
 (0)
Please sign in to comment.