KDAB / KDDockWidgets

KDAB's Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets
Other
762 stars 164 forks source link

Crash in KDDockWidgets::DockWidgetInstantiator::isFocusedChanged #501

Closed msarehn closed 5 months ago

msarehn commented 5 months ago

Sometimes, although not reliably, KDDockWidgets (QtQuick backend) crashes when closing a DockWidget.

We've already had similar crashes before with 2.0. We've bumped to 2.1-dev because it includes b7db57c1 (Do not emit isFocusedChanged in a delayed manner) which improves the situation a little bit, but does not get rid of the crashes completely.

FWIW, we do have a commercial license for KDDW.

Details

Version: 2.1-dev commit 497f65f2

Backtrace ``` Thread 1 "coreui" received signal SIGSEGV, Segmentation fault. 0x00007ffff2824dc1 in QObjectPrivate::maybeSignalConnected(unsigned int) const () from /opt/qt6/lib/libQt6Core.so.6 (gdb) bt #0 0x00007ffff2824dc1 in QObjectPrivate::maybeSignalConnected(unsigned int) const () from /opt/qt6/lib/libQt6Core.so.6 #1 0x00007ffff2834ca8 in void doActivate(QObject*, int, void**) () from /opt/qt6/lib/libQt6Core.so.6 #2 0x00007ffff6eb4f6e in KDDockWidgets::DockWidgetInstantiator::isFocusedChanged (this=0x5555563e7230, _t1=false) at /home/arehn/src/build-dcf-ecosystem-Menlo_Qt6_6_6_0-Debug/coreui/3rdparty/KDDockWidgets/src/kddockwidgets_autogen/5PJCAAPZ7B/moc_DockWidgetInstantiator.cpp:812 #3 0x00007ffff737b772 in KDDockWidgets::DockWidgetInstantiator::::operator()(bool) const (__closure=0x555556251ea0, is=false) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/qtquick/DockWidgetInstantiator.cpp:228 #4 0x00007ffff73809b5 in std::_Function_handler >::_M_invoke(const std::_Any_data &, bool &&) (__functor=..., __args#0=@0x7fffffffc524: false) at /usr/include/c++/9/bits/std_function.h:300 #5 0x00007ffff6f0ed38 in std::function::operator()(bool) const (this=0x555556251ea0, __args#0=false) at /usr/include/c++/9/bits/std_function.h:688 #6 0x00007ffff6f0e4cd in KDBindings::Signal::Impl::emit (this=0x5555562519b0, p#0=false) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/3rdparty/kdbindings/signal.h:301 #7 0x00007ffff6f0e00b in KDBindings::Signal::emit (this=0x55555624d940, p#0=false) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/3rdparty/kdbindings/signal.h:494 #8 0x00007ffff7085b1d in KDDockWidgets::DockRegistry::setFocusedDockWidget (this=0x5555556b1bc0, dw=0x0) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/core/DockRegistry.cpp:123 #9 0x00007ffff70857db in KDDockWidgets::DockRegistry::onFocusedViewChanged (this=0x5555556b1bc0, view= std::shared_ptr (use count 3, weak count 1) = {...}) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/core/DockRegistry.cpp:111 #10 0x00007ffff70c1743 in std::__invoke_impl), KDDockWidgets::DockRegistry*&, std::shared_ptr > (__f= @0x5555556b1e30: (void (KDDockWidgets::DockRegistry::*)(class KDDockWidgets::DockRegistry * const, class std::shared_ptr)) 0x7ffff708547a )>, __t=@0x5555556b1e40: 0x5555556b1bc0) at /usr/include/c++/9/bits/invoke.h:73 #11 0x00007ffff70b9bed in std::__invoke), KDDockWidgets::DockRegistry*&, std::shared_ptr > (__fn= @0x5555556b1e30: (void (KDDockWidgets::DockRegistry::*)(class KDDockWidgets::DockRegistry * const, class std::shared_ptr)) 0x7ffff708547a )>) at /usr/include/c++/9/bits/invoke.h:95 #12 0x00007ffff70affcf in std::_Bind))(std::shared_ptr)>::__call&&, 0ul, 1ul>(std::tuple&&>&&, std::_Index_tuple<0ul, 1ul>) (this=0x5555556b1e30, __args=...) at /usr/include/c++/9/functional:400 #13 0x00007ffff70a584b in std::_Bind))(std::shared_ptr)>::operator(), void>(std::shared_ptr&&) (this=0x5555556b1e30) at /usr/include/c++/9/functional:484 #14 0x00007ffff709ec5a in std::_Function_handler), std::_Bind))(std::shared_ptr)> >::_M_invoke(std::_Any_data const&, std::shared_ptr&&) (__functor=..., __args#0=...) at /usr/include/c++/9/bits/std_function.h:300 #15 0x00007ffff72a7bf5 in std::function)>::operator()(std::shared_ptr) const (this=0x555555ba67e8, __args#0=std::shared_ptr (empty) = {...}) at /usr/include/c++/9/bits/std_function.h:688 --Type for more, q to quit, c to continue without paging-- #16 0x00007ffff72a78e2 in KDBindings::Signal >::Impl::emit (this=0x5555556b1dd0, p#0=std::shared_ptr (use count 3, weak count 1) = {...}) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/3rdparty/kdbindings/signal.h:301 #17 0x00007ffff72a74e9 in KDBindings::Signal >::emit (this=0x5555556b1920, p#0=std::shared_ptr (use count 3, weak count 1) = {...}) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/3rdparty/kdbindings/signal.h:494 #18 0x00007ffff736d313 in KDDockWidgets::QtQuick::Platform::::operator()(QObject *) const (__closure=0x5555556b50a0, obj=0x5555556f1680) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/qtquick/Platform.cpp:90 #19 0x00007ffff736f715 in QtPrivate::FunctorCall, QtPrivate::List, void, KDDockWidgets::QtQuick::Platform::init():: >::call(KDDockWidgets::QtQuick::Platform:: &, void **) (f=..., arg=0x7fffffffcb40) at /opt/qt6/include/QtCore/qobjectdefs_impl.h:137 #20 0x00007ffff736f64b in QtPrivate::Functor, 1>::call, void>(KDDockWidgets::QtQuick::Platform:: &, void *, void **) (f=..., arg=0x7fffffffcb40) at /opt/qt6/include/QtCore/qobjectdefs_impl.h:339 #21 0x00007ffff736f5b6 in QtPrivate::QCallableObject, QtPrivate::List, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=1, this_=0x5555556b5090, r=0x5555555b10d0, a=0x7fffffffcb40, ret=0x0) at /opt/qt6/include/QtCore/qobjectdefs_impl.h:522 #22 0x00007ffff2834df3 in void doActivate(QObject*, int, void**) () from /opt/qt6/lib/libQt6Core.so.6 #23 0x00007ffff2f2feb6 in QGuiApplication::focusObjectChanged(QObject*) () from /opt/qt6/lib/libQt6Gui.so.6 #24 0x00007ffff2f397d2 in QGuiApplication::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) () from /opt/qt6/lib/libQt6Gui.so.6 #25 0x00007ffff2835177 in void doActivate(QObject*, int, void**) () from /opt/qt6/lib/libQt6Core.so.6 #26 0x00007ffff2f92b96 in QWindow::focusObjectChanged(QObject*) () from /opt/qt6/lib/libQt6Gui.so.6 #27 0x00007ffff1e09ab6 in QQuickDeliveryAgentPrivate::clearFocusInScope(QQuickItem*, QQuickItem*, Qt::FocusReason, QFlags) () from /opt/qt6/lib/libQt6Quick.so.6 #28 0x00007ffff1c66463 in QQuickItem::setParentItem(QQuickItem*) () from /opt/qt6/lib/libQt6Quick.so.6 #29 0x00007ffff1c67343 in QQuickItem::~QQuickItem() () from /opt/qt6/lib/libQt6Quick.so.6 #30 0x00007ffff6ef3cf7 in KDDockWidgets::QtQuick::View::~View (this=0x555556280d10, __in_chrg=) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/qtquick/views/View.h:67 #31 0x00007ffff739a654 in KDDockWidgets::QtQuick::Group::~Group (this=0x555556280d10, __in_chrg=) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/qtquick/views/Group.cpp:66 #32 0x00007ffff739a6c4 in KDDockWidgets::QtQuick::Group::~Group (this=0x555556280d10, __in_chrg=) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/qtquick/views/Group.cpp:75 #33 0x00007ffff71fc62d in KDDockWidgets::Core::View::Private::free (this=0x5555563e43c0) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/core/View.cpp:100 #34 0x00007ffff71ef037 in KDDockWidgets::Core::Controller::~Controller (this=0x555555ba2fa0, __in_chrg=) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/core/Controller.cpp:37 #35 0x00007ffff7142fcc in KDDockWidgets::Core::Group::~Group (this=0x555555ba2fa0, __in_chrg=) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/core/Group.cpp:117 #36 0x00007ffff7143024 in KDDockWidgets::Core::Group::~Group (this=0x555555ba2fa0, __in_chrg=) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/core/Group.cpp:134 #37 0x00007ffff740abb3 in KDDockWidgets::Core::DelayedDelete::call (this=0x55555637fe40) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/core/DelayedCall.cpp:41 --Type for more, q to quit, c to continue without paging-- #38 0x00007ffff73ef037 in KDDockWidgets::QtCommon::Platform_qt::::operator()(void) const (__closure=0x5555560e2760) at /home/arehn/src/dcf-ecosystem/coreui/3rdparty/KDDockWidgets/src/qtcommon/Platform.cpp:330 #39 0x00007ffff73efbe2 in QtPrivate::FunctorCall, QtPrivate::List<>, void, KDDockWidgets::QtCommon::Platform_qt::runDelayed(int, KDDockWidgets::Core::DelayedCall*):: >::call(KDDockWidgets::QtCommon::Platform_qt:: &, void **) (f=..., arg=0x555556bd72b8) at /opt/qt6/include/QtCore/qobjectdefs_impl.h:137 #40 0x00007ffff73efb8f in QtPrivate::Functor, 0>::call, void>(KDDockWidgets::QtCommon::Platform_qt:: &, void *, void **) (f=..., arg=0x555556bd72b8) at /opt/qt6/include/QtCore/qobjectdefs_impl.h:339 #41 0x00007ffff73efafa in QtPrivate::QCallableObject, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=1, this_=0x5555560e2750, r=0x5555555b10d0, a=0x555556bd72b8, ret=0x0) at /opt/qt6/include/QtCore/qobjectdefs_impl.h:522 #42 0x00007ffff282696b in QObject::event(QEvent*) () from /opt/qt6/lib/libQt6Core.so.6 #43 0x00007ffff2f3cf13 in QGuiApplication::event(QEvent*) () from /opt/qt6/lib/libQt6Gui.so.6 #44 0x00007ffff27d645a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /opt/qt6/lib/libQt6Core.so.6 #45 0x00007ffff27d9e35 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /opt/qt6/lib/libQt6Core.so.6 #46 0x00007ffff2a8e2e7 in postEventSourceDispatch(_GSource*, int (*)(void*), void*) () from /opt/qt6/lib/libQt6Core.so.6 #47 0x00007ffff00b317d in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #48 0x00007ffff00b3400 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #49 0x00007ffff00b34a3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #50 0x00007ffff2a8dbe8 in QEventDispatcherGlib::processEvents(QFlags) () from /opt/qt6/lib/libQt6Core.so.6 #51 0x00007ffff27e1e03 in QEventLoop::exec(QFlags) () from /opt/qt6/lib/libQt6Core.so.6 #52 0x00007ffff27de3f6 in QCoreApplication::exec() () from /opt/qt6/lib/libQt6Core.so.6 #53 0x00007ffff6d62253 in guimain (args=...) at /home/arehn/src/dcf-ecosystem/coreui/src/coreui-shared.cpp:370 #54 0x0000555555563c50 in main (argc=4, argv=0x7fffffffe1a8) at /home/arehn/src/dcf-ecosystem/coreui/src/main.cpp:40 ```
iamsergio commented 5 months ago

Hi,

Is it repro with the example ./bin/qtquick_dockwidgets ? Which flags are you passing to Config::setFlags() ?

msarehn commented 5 months ago

Is it repro with the example ./bin/qtquick_dockwidgets ?

Nope.

Which flags are you passing to Config::setFlags() ?

None, we don't call this. Its at the default.

iamsergio commented 5 months ago

@msarehn I can't reproduce, but I understand why it happened. Should be fixed, please test latest 2.1 branch

msarehn commented 5 months ago

@iamsergio that was quick, thanks! I was going through the code and arrived at the same solution the very moment you've pushed the fix.

Works as intendend, doesn't crash anymore 👍