QTextDocument::loadResource(): invoke parent via direct connection

If QTextDocument::loadResource() gets called from a different thread
than the thread that the QTD object (and *necessarily* its parent, if it
has one) live in, we would get the warning "Unable to invoke methods
with return values in queued connections". Rather, ensure that it's
invoked only via a direct connection.

Amends ac300a166f801a6f6c0b15278e6893720a5726f8

Task-number: QTBUG-35688
Change-Id: I35644f7cd54b1f40362d3d45c2a120883f7a2e61
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 963f3c678ca8282bd3e1d8af5f8669baaddb1686)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Shawn Rutledge 2022-11-07 20:30:39 +01:00 committed by Qt Cherry-pick Bot
parent bc9b03a43b
commit 852c40f290

View File

@ -2235,7 +2235,8 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name)
int index = me->indexOfMethod("loadResource(int,QUrl)");
if (index >= 0) {
QMetaMethod loader = me->method(index);
loader.invoke(p, Q_RETURN_ARG(QVariant, r), Q_ARG(int, type), Q_ARG(QUrl, name));
// don't invoke() via a queued connection: this function needs to return a value
loader.invoke(p, Qt::DirectConnection, Q_RETURN_ARG(QVariant, r), Q_ARG(int, type), Q_ARG(QUrl, name));
}
}