Skip to content

Commit

Permalink
Merge pull request #6040 from signedav/crashfix
Browse files Browse the repository at this point in the history
mapLayerActions as members - avoiding crash on closing QGIS

Fix #17839
  • Loading branch information
m-kuhn committed Jan 12, 2018
2 parents d6ef2b6 + ff96e1d commit 074db04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/app/qgisapp.cpp
Expand Up @@ -7451,23 +7451,23 @@ void QgisApp::setupLayoutManagerConnections()

void QgisApp::setupDuplicateFeaturesAction()
{
QgsMapLayerAction *action = new QgsMapLayerAction( QString( tr( "Duplicate feature" ) ),
this, QgsMapLayerAction::AllActions,
QgsApplication::getThemeIcon( QStringLiteral( "/mActionDuplicateFeature.svg" ) ) );
mDuplicateFeatureAction.reset( new QgsMapLayerAction( tr( "Duplicate feature" ),
nullptr, QgsMapLayerAction::SingleFeature,
QgsApplication::getThemeIcon( QStringLiteral( "/mActionDuplicateFeature.svg" ) ) ) );

QgsGui::mapLayerActionRegistry()->addMapLayerAction( action );
connect( action, &QgsMapLayerAction::triggeredForFeature, this, [this]( QgsMapLayer * layer, const QgsFeature & feat )
QgsGui::mapLayerActionRegistry()->addMapLayerAction( mDuplicateFeatureAction.get() );
connect( mDuplicateFeatureAction.get(), &QgsMapLayerAction::triggeredForFeature, this, [this]( QgsMapLayer * layer, const QgsFeature & feat )
{
duplicateFeatures( layer, feat );
}
);

action = new QgsMapLayerAction( QString( tr( "Duplicate feature and digitize" ) ),
this, QgsMapLayerAction::AllActions,
QgsApplication::getThemeIcon( QStringLiteral( "/mActionDuplicateFeatureDigitized.svg" ) ) );
mDuplicateFeatureDigitizeAction.reset( new QgsMapLayerAction( tr( "Duplicate feature and digitize" ),
nullptr, QgsMapLayerAction::SingleFeature,
QgsApplication::getThemeIcon( QStringLiteral( "/mActionDuplicateFeatureDigitized.svg" ) ) ) );

QgsGui::mapLayerActionRegistry()->addMapLayerAction( action );
connect( action, &QgsMapLayerAction::triggeredForFeature, this, [this]( QgsMapLayer * layer, const QgsFeature & feat )
QgsGui::mapLayerActionRegistry()->addMapLayerAction( mDuplicateFeatureDigitizeAction.get() );
connect( mDuplicateFeatureDigitizeAction.get(), &QgsMapLayerAction::triggeredForFeature, this, [this]( QgsMapLayer * layer, const QgsFeature & feat )
{
duplicateFeatureDigitized( layer, feat );
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -2146,6 +2146,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

QHash< QgsPrintLayout *, QgsMapLayerAction * > mAtlasFeatureActions;

std::unique_ptr<QgsMapLayerAction> mDuplicateFeatureAction;
std::unique_ptr<QgsMapLayerAction> mDuplicateFeatureDigitizeAction;

int mProjOpen = 0;

bool gestureEvent( QGestureEvent *event );
Expand Down

0 comments on commit 074db04

Please sign in to comment.