Skip to content

Commit 6424ceb

Browse files
committed
[options search] move Message bar items check to QgsSearchHighlightOptionWidget constructor
1 parent 3b14380 commit 6424ceb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/gui/qgsoptionsdialogbase.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@ void QgsOptionsDialogBase::registerTextSearchWidgets()
265265
{
266266
Q_FOREACH ( QWidget *w, mOptStackedWidget->widget( i )->findChildren<QWidget *>() )
267267
{
268-
// do not register message bar content, items disappear and causes QGIS to crash
269-
if ( qobject_cast< QgsMessageBarItem * >( w ) || qobject_cast< QgsMessageBarItem * >( w->parentWidget() ) )
270-
continue;
271-
272268
QgsSearchHighlightOptionWidget *shw = new QgsSearchHighlightOptionWidget( w );
273269
if ( shw->isValid() )
274270
{
@@ -399,6 +395,17 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
399395
: QObject( widget )
400396
, mWidget( widget )
401397
{
398+
QWidget *parent = widget;
399+
while ( ( parent = parent->parentWidget() ) )
400+
{
401+
// do not register message bar content, items disappear and causes QGIS to crash
402+
if ( qobject_cast< QgsMessageBarItem * >( parent ) )
403+
{
404+
mValid = false;
405+
return;
406+
}
407+
}
408+
402409
if ( qobject_cast<QLabel *>( widget ) )
403410
{
404411
mStyleSheet = QStringLiteral( "QLabel { background-color: yellow; color: blue;}" );

0 commit comments

Comments
 (0)