diff options
-rw-r--r-- | src/library/librarycontrol.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index 3ae1ea450a..840aed41a1 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -562,17 +562,26 @@ void LibraryControl::emitKeyEvent(QKeyEvent&& event) { } void LibraryControl::setLibraryFocus() { - // XXX: Set the focus of the library panel directly instead of sending tab from sidebar + // TODO: Set the focus of the library panel directly instead of sending tab from sidebar VERIFY_OR_DEBUG_ASSERT(m_pSidebarWidget) { return; } + // 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()) { + return; + } + // Send Tab to move focus to the Tracks table. + // Obviously only works as desired if the skin widgets are arranged + // accordingly. QKeyEvent event(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier); QApplication::sendEvent(m_pSidebarWidget, &event); } void LibraryControl::slotSelectSidebarItem(double v) { - if (m_pSidebarWidget == NULL) { + VERIFY_OR_DEBUG_ASSERT(m_pSidebarWidget) { return; } if (v > 0) { |