Skip to content

Commit e465c0a

Browse files
committed
fix(qt6): Fix infinite loop crash in QQmlProxyMetaObject
Qt6 port is now complete, as its tests all pass with this fix. Don't emit signals in an extension after its target widget dtors have already started. QQmlProxyMetaObject doesn't like its parents meta-objects offsets changing.
1 parent 5eb3d0f commit e465c0a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ add_library(
6060
target_link_libraries(
6161
${TARGET}
6262
PRIVATE Qt${QTMAJOR}::Core Qt${QTMAJOR}::CorePrivate Qt${QTMAJOR}::Qml
63-
Qt${QTMAJOR}::Widgets Qt${QTMAJOR}::QuickWidgets)
63+
Qt${QTMAJOR}::Widgets Qt${QTMAJOR}::WidgetsPrivate
64+
Qt${QTMAJOR}::QuickWidgets)
6465

6566
if(Qt${QTMAJOR}WebEngineWidgets_FOUND)
6667
target_link_libraries(${TARGET} PRIVATE Qt${QTMAJOR}::WebEngineWidgets)

src/declarativewidgetextension.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <QLayout>
4040
#include <QQmlInfo>
4141
#include <QWidget>
42+
#include <QtWidgets/private/qwidget_p.h>
4243

4344
class WidgetContainerDelegate : public DefaultObjectContainer
4445
{
@@ -207,6 +208,15 @@ bool DeclarativeWidgetExtension::eventFilter(QObject *watched, QEvent *event)
207208
Q_ASSERT(watched == parent());
208209
Q_UNUSED(watched); // release builds
209210

211+
if (auto w = extendedWidget()) {
212+
// This fixes infinite loop QQmlProxyMetaObject::metaCall()
213+
// Don't emit signals in an extension after its target widget dtors have already started.
214+
// QQmlProxyMetaObject doesn't like its parents meta-objects offsets changing
215+
QWidgetPrivate *priv = QWidgetPrivate::get(w);
216+
if (priv && priv->data.in_destructor)
217+
return false;
218+
}
219+
210220
switch (event->type())
211221
{
212222
case QEvent::Move:

0 commit comments

Comments
 (0)