Skip to content
Permalink
Browse files
Merge pull request #350 from matthias-kuhn/qgsmessagebar
Transfer ownership of widgets to C++ when pushed to the QgsMessageBar
  • Loading branch information
wonder-sk committed Dec 28, 2012
2 parents 837f187 + 2b2da5d commit 5df8f2cb06e346c44f0c9c5e66ab1ebb0ca5f22b
Showing with 10 additions and 2 deletions.
  1. +1 −1 python/gui/qgsmessagebar.sip
  2. +9 −1 src/gui/qgsmessagebar.cpp
@@ -13,7 +13,7 @@ class QgsMessageBar: QFrame
* @param widget widget to add
* @param level is 0 for information, 1 for warning, 2 for critical
*/
void pushWidget( QWidget *widget, int level = 0 );
void pushWidget( QWidget *widget /Transfer/, int level = 0 );

/*! remove the passed widget from the bar (if previously added),
* then display the next one in the stack if any or hide the bar
@@ -90,6 +90,11 @@ void QgsMessageBar::popItem( QgsMessageBarItem *item )
{
mLayout->removeWidget( mCurrentItem->widget() );
mCurrentItem->widget()->hide();
if ( mCurrentItem->widget()->parent() == this )
{
delete mCurrentItem->widget();
}
delete mCurrentItem;
mCurrentItem = 0;
}

@@ -126,6 +131,10 @@ bool QgsMessageBar::popWidget( QWidget *widget )
if ( item->widget() == widget )
{
mList.removeOne( item );
if ( item->widget()->parent() == this )
{
delete item->widget();
}
delete item;
return true;
}
@@ -141,7 +150,6 @@ bool QgsMessageBar::popWidget()

QgsMessageBarItem *item = mCurrentItem;
popItem( item );
delete item;

return true;
}

0 comments on commit 5df8f2c

Please sign in to comment.