From 94a58121f770620b77d43b7f4559512997949f55 Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Mon, 3 Dec 2018 16:02:21 +0000 Subject: [PATCH] Fix crash on setting the accelerator table in wxQt Check whether m_qtShortcuts is non-null before dereferencing it. Closes https://github.com/wxWidgets/wxWidgets/pull/1040 --- src/qt/window.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/qt/window.cpp b/src/qt/window.cpp index 87feb5ecb7..8342db8c74 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -936,13 +936,17 @@ void wxWindowQt::SetAcceleratorTable( const wxAcceleratorTable& accel ) { wxWindowBase::SetAcceleratorTable( accel ); - // Disable previously set accelerators - while ( !m_qtShortcuts->isEmpty() ) - delete m_qtShortcuts->takeFirst(); + if ( m_qtShortcuts ) + { + // Disable previously set accelerators + while ( !m_qtShortcuts->isEmpty() ) + delete m_qtShortcuts->takeFirst(); + + // Create new shortcuts (use GetHandle() so all events inside + // the window are handled, not only in the container subwindow) + delete m_qtShortcuts; + } - // Create new shortcuts (use GetHandle() so all events inside - // the window are handled, not only in the container subwindow) - delete m_qtShortcuts; m_qtShortcuts = accel.ConvertShortcutTable( GetHandle() ); // Connect shortcuts to window