void DockContainer::popupMenu(QPoint p) { KMenu *pm = new KMenu(this); QAction *kill = pm->addAction( i18n("Kill This Applet")); QAction *change = pm->addAction( i18n("Change Command")); QAction *r = pm->exec(p); /* pm is destroyed now .. if it is destroyed later, there is a risk that kill() double-frees it */ delete pm; if (r == kill) this->kill(); if (r == change) askNewCommand(false); }
void DockContainer::popupMenu(QPoint p) { int r; { KPopupMenu pm(this); pm.insertItem( i18n("Kill This Applet"), 0); pm.insertItem( i18n("Change Command"), 1); r = pm.exec(p); /* pm is destroyed now .. if it is destroyed later, there is a risk that kill() double-frees it */ } switch (r) { case 0: { kill(); } break; case 1: { askNewCommand(false); } break; } }