Skip to content
Permalink
Browse files

fix an options dialog search crasher (#5978)

  • Loading branch information
nirvn committed Jan 4, 2018
1 parent d69f932 commit 13ad7608e894f7d6f8903e28548a514decb78cad
Showing with 10 additions and 5 deletions.
  1. +7 −2 src/gui/qgsoptionsdialogbase.cpp
  2. +3 −3 src/gui/qgsoptionsdialogbase.h
@@ -35,7 +35,7 @@
#include <QAbstractItemModel>

#include "qgsfilterlineedit.h"

#include "qgsmessagebaritem.h"
#include "qgslogger.h"

QgsOptionsDialogBase::QgsOptionsDialogBase( const QString &settingsKey, QWidget *parent, Qt::WindowFlags fl, QgsSettings *settings )
@@ -265,6 +265,10 @@ void QgsOptionsDialogBase::registerTextSearchWidgets()
{
Q_FOREACH ( QWidget *w, mOptStackedWidget->widget( i )->findChildren<QWidget *>() )
{
// do not register message bar content, items disappear and causes QGIS to crash
if ( qobject_cast< QgsMessageBarItem * >( w ) || qobject_cast< QgsMessageBarItem * >( w->parentWidget() ) )
continue;

QgsSearchHighlightOptionWidget *shw = new QgsSearchHighlightOptionWidget( w );
if ( shw->isValid() )
{
@@ -471,7 +475,7 @@ bool QgsSearchHighlightOptionWidget::searchHighlight( const QString &searchText

void QgsSearchHighlightOptionWidget::reset()
{
if ( mValid && mChangedStyle )
if ( mWidget && mValid && mChangedStyle )
{
QString ss = mWidget->styleSheet();
ss.remove( mStyleSheet );
@@ -482,5 +486,6 @@ void QgsSearchHighlightOptionWidget::reset()

void QgsSearchHighlightOptionWidget::widgetDestroyed()
{
mWidget = nullptr;
mValid = false;
}
@@ -62,7 +62,7 @@ class GUI_EXPORT QgsSearchHighlightOptionWidget : public QObject
/**
* Returns if it valid: if the widget type is handled and if the widget is not still available
*/
bool isValid() {return mValid;}
bool isValid() { return mWidget && mValid; }

/**
* search for a text pattern and highlight the widget if the text is found
@@ -78,13 +78,13 @@ class GUI_EXPORT QgsSearchHighlightOptionWidget : public QObject
/**
* return the widget
*/
QWidget *widget() {return mWidget;}
QWidget *widget() { return mWidget; }

private slots:
void widgetDestroyed();

private:
QWidget *mWidget = nullptr;
QPointer< QWidget > mWidget;
QString mStyleSheet;
bool mValid = true;
bool mChangedStyle = false;

0 comments on commit 13ad760

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