From 9e19a76a5a00bd52835641a7a5c47045fccd3999 Mon Sep 17 00:00:00 2001 From: Agel Date: Thu, 16 Apr 2026 22:50:03 +0200 Subject: [PATCH] Fix thread warning --- scripts/install-deps-macos.sh | 1 + src/backend/formats/WebImageProvider.cpp | 10 ++++++++++ src/qml/Main.qml | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/scripts/install-deps-macos.sh b/scripts/install-deps-macos.sh index 487917f..ffaa610 100755 --- a/scripts/install-deps-macos.sh +++ b/scripts/install-deps-macos.sh @@ -21,6 +21,7 @@ sudo mkdir -p /opt/qt sudo chown "$USER" /opt/qt /tmp/aqt-venv/bin/aqt install-qt mac desktop 6.10.3 "$QT_ARCH" \ -m qtimageformats qtpdf --outputdir /opt/qt +/tmp/aqt-venv/bin/aqt install-src mac 6.10.3 --outputdir /opt/qt rm -rf /tmp/aqt-venv QT_DIR="/opt/qt/6.10.3/$QT_DIR_NAME" diff --git a/src/backend/formats/WebImageProvider.cpp b/src/backend/formats/WebImageProvider.cpp index fb226c8..4d78513 100644 --- a/src/backend/formats/WebImageProvider.cpp +++ b/src/backend/formats/WebImageProvider.cpp @@ -159,6 +159,16 @@ void WebImageResponse::run() QQuickImageResponse *WebImageProvider::requestImageResponse(const QString &id, const QSize &requestedSize) { + // Warmup request: pre-creates QQuickPixmapReader on the main thread at + // startup so the render thread never creates it first (which would trigger + // a "Cannot create children for a parent in a different thread" warning). + // Return an empty response immediately — no network request needed. + if (id == QLatin1String("__warmup__")) { + auto *response = new WebImageResponse(id, 0, requestedSize); + QMetaObject::invokeMethod(response, "finished", Qt::QueuedConnection); + return response; + } + int displayWidth; { QMutexLocker lock(&m_mutex); diff --git a/src/qml/Main.qml b/src/qml/Main.qml index 81d2bff..2a4a602 100644 --- a/src/qml/Main.qml +++ b/src/qml/Main.qml @@ -167,6 +167,10 @@ ApplicationWindow { z: 3000 } + // Pre-warms QQuickPixmapReader on the main thread so the render thread + // never creates it first (which logs a QObject parent-thread warning). + Image { width: 0; height: 0; visible: false; source: "image://web/__warmup__" } + // Navigate once measurement (and position restoration) is done Connections { target: readingModel