mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Don't spam message bar with more of the same error
This commit is contained in:
parent
6cf2dd0a4c
commit
216821ff38
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user