mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-25 09:11:28 -05:00
fixed memory leak in SubscribeToolButton menu
This commit is contained in:
parent
55e80871eb
commit
52cf66a536
@ -10,6 +10,7 @@ SubscribeToolButton::SubscribeToolButton(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
mSubscribed = false;
|
mSubscribed = false;
|
||||||
|
|
||||||
|
mMenu = NULL ;
|
||||||
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
|
|
||||||
#ifdef USE_MENUBUTTONPOPUP
|
#ifdef USE_MENUBUTTONPOPUP
|
||||||
@ -46,14 +47,18 @@ void SubscribeToolButton::updateUi()
|
|||||||
setIcon(QIcon(":/images/accepted16.png"));
|
setIcon(QIcon(":/images/accepted16.png"));
|
||||||
setText(tr("Subscribed"));
|
setText(tr("Subscribed"));
|
||||||
|
|
||||||
QMenu *menu = new QMenu;
|
if(mMenu != NULL) // that's because setMenu does not give away memory ownership
|
||||||
menu->addAction(QIcon(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate()));
|
delete mMenu ;
|
||||||
|
|
||||||
|
mMenu = new QMenu;
|
||||||
|
mMenu->addAction(QIcon(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate()));
|
||||||
|
|
||||||
if (!mSubscribedActions.empty()) {
|
if (!mSubscribedActions.empty()) {
|
||||||
menu->addSeparator();
|
mMenu->addSeparator();
|
||||||
menu->addActions(mSubscribedActions);
|
mMenu->addActions(mSubscribedActions);
|
||||||
}
|
}
|
||||||
setMenu(menu);
|
|
||||||
|
setMenu(mMenu);
|
||||||
|
|
||||||
#ifndef USE_MENUBUTTONPOPUP
|
#ifndef USE_MENUBUTTONPOPUP
|
||||||
disconnect(this, SIGNAL(clicked()), this, SLOT(subscribePrivate()));
|
disconnect(this, SIGNAL(clicked()), this, SLOT(subscribePrivate()));
|
||||||
|
@ -26,6 +26,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
bool mSubscribed;
|
bool mSubscribed;
|
||||||
QList<QAction*> mSubscribedActions;
|
QList<QAction*> mSubscribedActions;
|
||||||
|
QMenu *mMenu ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SUBSCRIBETOOLBUTTON_H
|
#endif // SUBSCRIBETOOLBUTTON_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user