Skip to content

Commit

Permalink
Libarycontrol: backport of #3198: fix crash when trying to refocus th…
Browse files Browse the repository at this point in the history
…e library while another Mixxx window has focus
  • Loading branch information
ronso0 committed Oct 22, 2020
1 parent c0cd88a commit f2bfe7f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,25 @@ void LibraryControl::emitKeyEvent(QKeyEvent&& event) {
}

void LibraryControl::setLibraryFocus() {
if (m_pSidebarWidget) {
// XXX: Set the focus of the library panel directly instead of sending tab from sidebar
m_pSidebarWidget->setFocus();
// XXX: 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 has focus,
// so make sure the sidebar is focused or we'll crash.
if (m_pSidebarWidget->hasFocus()) {
// 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) {
Expand Down

0 comments on commit f2bfe7f

Please sign in to comment.