summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-10-29 16:08:06 +0100
committerGitHub <noreply@github.com>2020-10-29 16:08:06 +0100
commit90615111a5062472c1a17ecc2d7fb01b4defd9ef (patch)
tree3b29c0ab05fcd608c3608b0556ad2de638a36d80
parentf804f84754599b33f22fed84a8b4355e09c3be25 (diff)
parent8fdb9cb281dd84e379b3dd99af4e52f46eec6067 (diff)
Merge pull request #3201 from ronso0/libnavi-crash2.2
Libarycontrol: backport of #3198: fix crash when trying to refocus th…
-rw-r--r--src/library/librarycontrol.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp
index 117273d6d7..dc1ae985ba 100644
--- a/src/library/librarycontrol.cpp
+++ b/src/library/librarycontrol.cpp
@@ -405,16 +405,26 @@ 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();
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier);
- QApplication::sendEvent(m_pSidebarWidget, &event);
+ // 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) {
@@ -472,8 +482,8 @@ void LibraryControl::slotGoToItem(double v) {
slotToggleSelectedSidebarItem(v);
}
}
- // TODO(xxx) instead of remote control the widgets individual, we should
- // translate this into Alt+Return and handle it at each library widget
+ // TODO(xxx) instead of remote control the widgets individual, we should
+ // translate this into Alt+Return and handle it at each library widget
// individual https://bugs.launchpad.net/mixxx/+bug/1758618
//emitKeyEvent(QKeyEvent{QEvent::KeyPress, Qt::Key_Return, Qt::AltModifier});
}