Skip to content
Permalink
Browse files

guard message bar item with QPointer

  • Loading branch information
troopa81 authored and nyalldawson committed May 14, 2020
1 parent c867ba9 commit 6358baafcd8253f5944d2ea87b8bfea8b8b3289f
Showing with 5 additions and 6 deletions.
  1. +1 −4 src/gui/qgsmaskingwidget.cpp
  2. +4 −2 src/gui/qgsmaskingwidget.h
@@ -39,15 +39,12 @@ QgsMaskingWidget::QgsMaskingWidget( QWidget *parent ) :
void QgsMaskingWidget::onSelectionChanged()
{
// display message if configuration is not consistent
bool printMessage =
( mMaskTargetsWidget->selection().empty() && !mMaskSourcesWidget->selection().empty() )
|| ( !mMaskTargetsWidget->selection().empty() && mMaskSourcesWidget->selection().empty() );
bool printMessage = mMaskTargetsWidget->selection().empty() != mMaskSourcesWidget->selection().empty();

if ( mMessageBarItem && !printMessage )
{
mMessageBar->popWidget( mMessageBarItem );
delete mMessageBarItem;
mMessageBarItem = nullptr;
}
else if ( !mMessageBarItem && printMessage )
{
@@ -18,6 +18,8 @@
// We don't want to expose this in the public API
#define SIP_NO_FILE

#include <QPointer>

#include "qgspanelwidget.h"
#include "ui_qgsmaskingwidgetbase.h"
#include "qgis_sip.h"
@@ -53,7 +55,7 @@ class GUI_EXPORT QgsMaskingWidget: public QgsPanelWidget, private Ui::QgsMasking

void showEvent( QShowEvent * ) override;

protected slots:
private slots:

/**
* Called whenever mask sources or targets selection has changed
@@ -65,7 +67,7 @@ class GUI_EXPORT QgsMaskingWidget: public QgsPanelWidget, private Ui::QgsMasking
//! Populate the mask source and target widgets
void populate();

QgsMessageBarItem *mMessageBarItem = nullptr;
QPointer<QgsMessageBarItem> mMessageBarItem;
bool mMustPopulate = false;
};

0 comments on commit 6358baa

Please sign in to comment.
You can’t perform that action at this time.