Skip to content
Permalink
Browse files
Transfer ownership of widgets to C++ when pushed to the QgsMessageBar
  • Loading branch information
m-kuhn committed Dec 10, 2012
1 parent 05746de commit 2b2da5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
@@ -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 2b2da5d

Please sign in to comment.