Skip to content

Commit 5040f37

Browse files
committed
core/reloader: delay post-reload reload hooks
Ensures onReload runs after Component.onCompleted.
1 parent 5a038f0 commit 5040f37

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/reload.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <qcontainerfwd.h>
44
#include <qobject.h>
55
#include <qqmllist.h>
6+
#include <qtimer.h>
67

78
#include "generation.hpp"
89

@@ -12,8 +13,10 @@ void Reloadable::componentComplete() {
1213
if (this->engineGeneration != nullptr) {
1314
// When called this way there is no chance a reload will have old data,
1415
// but this will at least help prevent weird behaviors due to never getting a reload.
15-
if (this->engineGeneration->reloadComplete) this->reload();
16-
else {
16+
if (this->engineGeneration->reloadComplete) {
17+
// Delayed due to Component.onCompleted running after QQmlParserStatus::componentComplete.
18+
QTimer::singleShot(0, this, &Reloadable::onReloadFinished);
19+
} else {
1720
QObject::connect(
1821
this->engineGeneration,
1922
&EngineGeneration::reloadFinished,

0 commit comments

Comments
 (0)