Skip to content
Permalink
Browse files

Prevent flooding (and app freeze) of items added to the message bar

  • Loading branch information
nirvn committed Oct 30, 2018
1 parent f5a1b4e commit 4d33422fe2b91934bc3a34baae484cba87ebef84
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/gui/qgsmessagebar.cpp
@@ -298,6 +298,17 @@ QgsMessageBarItem *QgsMessageBar::pushWidget( QWidget *widget, Qgis::MessageLeve

void QgsMessageBar::pushMessage( const QString &title, const QString &text, Qgis::MessageLevel level, int duration )
{
// keep the number of items in the message bar to a maximum of 20, avoids flooding (and freezing) of the main window
if ( mItems.count() > 20 )
mItems.removeFirst();

// block duplicate items, avoids flooding (and freezing) of the main window
for ( auto it = mItems.constBegin(); it != mItems.constEnd(); ++it )
{
if ( level == ( *it )->level() && title == ( *it )->title() && text == ( *it )->text() )
return;
}

QgsMessageBarItem *item = new QgsMessageBarItem( title, text, level, duration );
pushItem( item );
}

0 comments on commit 4d33422

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