Fixed Qt context menus so that all child widgets are destroyed after the menu parent goes out of scope.

This commit is contained in:
Matthew Budd 2020-10-21 20:31:39 -04:00
parent 7c4c524152
commit f0c13a57ec
4 changed files with 24 additions and 24 deletions

View File

@ -3010,19 +3010,19 @@ void QAsmView::contextMenuEvent(QContextMenuEvent *event)
ctxMenuAddr = addr = asmEntry[line]->addr;
act = new QAction(tr("Add Breakpoint"), this);
act = new QAction(tr("Add Breakpoint"), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuAddBP(void)) );
act = new QAction(tr("Add Symbolic Debug Marker"), this);
act = new QAction(tr("Add Symbolic Debug Marker"), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuAddSym(void)) );
act = new QAction(tr("Add Bookmark"), this);
act = new QAction(tr("Add Bookmark"), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuAddBM(void)) );
act = new QAction(tr("Open Hex Editor"), this);
act = new QAction(tr("Open Hex Editor"), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuOpenHexEdit(void)) );
@ -3294,7 +3294,7 @@ void DebuggerStackDisplay::contextMenuEvent(QContextMenuEvent *event)
menu.addAction( act );
subMenu = menu.addMenu(tr("Display Bytes Per Line"));
group = new QActionGroup(this);
group = new QActionGroup(&menu);
group->setExclusive(true);

View File

@ -1753,22 +1753,22 @@ void QHexEdit::contextMenuEvent(QContextMenuEvent *event)
{
case MODE_NES_RAM:
{
act = new QAction(tr("Add Symbolic Debug Name"), this);
act = new QAction(tr("Add Symbolic Debug Name"), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addDebugSym(void)) );
sprintf( stmp, "Add Read Breakpoint for Address $%04X", addr );
act = new QAction(tr(stmp), this);
act = new QAction(tr(stmp), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addRamReadBP(void)) );
sprintf( stmp, "Add Write Breakpoint for Address $%04X", addr );
act = new QAction(tr(stmp), this);
act = new QAction(tr(stmp), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addRamWriteBP(void)) );
sprintf( stmp, "Add Execute Breakpoint for Address $%04X", addr );
act = new QAction(tr(stmp), this);
act = new QAction(tr(stmp), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addRamExecuteBP(void)) );
@ -1780,13 +1780,13 @@ void QHexEdit::contextMenuEvent(QContextMenuEvent *event)
{
jumpToRomValue = romAddr;
sprintf( stmp, "Go Here in ROM File: (%08X)", romAddr );
act = new QAction(tr(stmp), this);
act = new QAction(tr(stmp), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(jumpToROM(void)) );
}
}
act = new QAction(tr("Add Bookmark"), this);
act = new QAction(tr("Add Bookmark"), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addBookMarkCB(void)) );
}
@ -1794,30 +1794,30 @@ void QHexEdit::contextMenuEvent(QContextMenuEvent *event)
case MODE_NES_PPU:
{
sprintf( stmp, "Add Read Breakpoint for Address $%04X", addr );
act = new QAction(tr(stmp), this);
act = new QAction(tr(stmp), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addPpuReadBP(void)) );
sprintf( stmp, "Add Write Breakpoint for Address $%04X", addr );
act = new QAction(tr(stmp), this);
act = new QAction(tr(stmp), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addPpuWriteBP(void)) );
act = new QAction(tr("Add Bookmark"), this);
act = new QAction(tr("Add Bookmark"), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addBookMarkCB(void)) );
}
break;
case MODE_NES_OAM:
{
act = new QAction(tr("Add Bookmark"), this);
act = new QAction(tr("Add Bookmark"), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addBookMarkCB(void)) );
}
break;
case MODE_NES_ROM:
{
act = new QAction(tr("Add Bookmark"), this);
act = new QAction(tr("Add Bookmark"), &menu);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(addBookMarkCB(void)) );
}

View File

@ -417,7 +417,7 @@ void ppuPatternView_t::contextMenuEvent(QContextMenuEvent *event)
menu.addAction( act );
subMenu = menu.addMenu(tr("Palette Select"));
group = new QActionGroup(this);
group = new QActionGroup(&menu);
group->setExclusive(true);

View File

@ -143,13 +143,13 @@ int CustomEmulationSpeed(int spdPercent)
g_fpsScale = ((double)spdPercent) / 100.0f;
if (g_fpsScale < Slowest)
{
g_fpsScale = Slowest;
}
else if (g_fpsScale > Fastest)
{
g_fpsScale = Fastest;
}
{
g_fpsScale = Slowest;
}
else if (g_fpsScale > Fastest)
{
g_fpsScale = Fastest;
}
RefreshThrottleFPS();