mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
fix an options dialog search crasher (#5978)
This commit is contained in:
parent
d69f932c31
commit
13ad7608e8
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user