diff options
Diffstat (limited to 'src/library/librarycontrol.cpp')
-rw-r--r-- | src/library/librarycontrol.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index ae747479f4..f69af79e7e 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -603,10 +603,13 @@ void LibraryControl::emitKeyEvent(QKeyEvent&& event) { if (keyIsTab && !QApplication::focusWidget()){ setLibraryFocus(); } + // Send the event pointer to the currently focused widget auto focusWidget = QApplication::focusWidget(); - for (auto i = 0; i < event.count(); ++i) { - QApplication::sendEvent(focusWidget, &event); + if (focusWidget) { + for (auto i = 0; i < event.count(); ++i) { + QApplication::sendEvent(focusWidget, &event); + } } } @@ -617,6 +620,7 @@ void LibraryControl::setLibraryFocus() { } // Try to focus the sidebar. m_pSidebarWidget->setFocus(); + // This may have failed, for example when a Cover window still has focus, // so make sure the sidebar is focused or we'll crash. if (!m_pSidebarWidget->hasFocus()) { |