mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 21:10:42 +00:00
Unregister shortcuts when closing windows that registered shortcuts
* This prevents leaking for cases where new widgets are created (and the small chance a widget pointer could be re-used and cause serious problems), and multiple-registration errors for global shortcuts.
This commit is contained in:
@@ -249,6 +249,12 @@ MainWindow::MainWindow(ICaptureContext &ctx) : QMainWindow(NULL), ui(new Ui::Mai
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
// explicitly delete our children here, so that the MainWindow is still alive while they are
|
||||
// closing.
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
qDeleteAll(findChildren<QWidget *>(QString(), Qt::FindDirectChildrenOnly));
|
||||
|
||||
m_RemoteProbeSemaphore.acquire();
|
||||
m_RemoteProbe->wait();
|
||||
m_RemoteProbe->deleteLater();
|
||||
@@ -1376,6 +1382,31 @@ void MainWindow::RegisterShortcut(const QString &shortcut, QWidget *widget, Shor
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::UnregisterShortcut(const QString &shortcut, QWidget *widget)
|
||||
{
|
||||
if(widget)
|
||||
{
|
||||
if(shortcut.isEmpty())
|
||||
{
|
||||
// if no shortcut is specified, remove all shortcuts for this widget
|
||||
for(QMap<QWidget *, ShortcutCallback> &sh : m_WidgetShortcutCallbacks)
|
||||
sh.remove(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
QKeySequence ks = QKeySequence::fromString(shortcut);
|
||||
|
||||
m_WidgetShortcutCallbacks[ks].remove(widget);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QKeySequence ks = QKeySequence::fromString(shortcut);
|
||||
|
||||
m_GlobalShortcutCallbacks.remove(ks);
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if(event->type() == QEvent::ShortcutOverride)
|
||||
|
||||
Reference in New Issue
Block a user