Skip to content
Permalink
Browse files

Don't spam message bar with more of the same error

  • Loading branch information
NathanW2 committed Sep 28, 2015
1 parent 6cf2dd0 commit 216821ff382df8f5c01caaa179ebded8d022481a
Showing with 10 additions and 0 deletions.
  1. +2 −0 python/gui/qgsmessagebar.sip
  2. +6 −0 python/utils.py
  3. +2 −0 src/gui/qgsmessagebar.h
@@ -49,6 +49,8 @@ class QgsMessageBar: QFrame
//! convenience method for pushing a message with title to the bar
void pushMessage( const QString &title, const QString &text, MessageLevel level = INFO, int duration = 0 );

QgsMessageBarItem *currentItem();

signals:
//! emitted when a message widget is added to the bar
void widgetAdded( QgsMessageBarItem *item );
@@ -87,7 +87,13 @@ def showException(type, value, tb, msg, messagebar=False):
QgsMessageLog.logMessage(logmessage, title)

if messagebar and iface:
item = iface.messageBar().currentItem()
if item and item.property("Error") == msg:
# Return of we already have a message with the same error message
return

widget = iface.messageBar().createMessage(title, msg + " See message log (Python Error) for more details.")
widget.setProperty("Error", msg)
button = QPushButton("View message log", pressed=iface.openMessageLog)
widget.layout().addWidget(button)
iface.messageBar().pushWidget(widget, QgsMessageBar.WARNING)
@@ -91,6 +91,8 @@ class GUI_EXPORT QgsMessageBar: public QFrame
//! convenience method for pushing a message with title to the bar
void pushMessage( const QString &title, const QString &text, MessageLevel level = INFO, int duration = 0 );

QgsMessageBarItem *currentItem() { return mCurrentItem; }

signals:
//! emitted when a message widget is added to the bar
void widgetAdded( QgsMessageBarItem *item );

0 comments on commit 216821f

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