diff options
-rw-r--r-- | lib/connection.cpp | 7 | ||||
-rw-r--r-- | lib/connection.h | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index efc7163e..f497601e 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -1622,11 +1622,14 @@ void Connection::setLazyLoading(bool newValue) } } -void Connection::run(BaseJob* job, RunningPolicy runningPolicy) +BaseJob* Connection::run(BaseJob* job, RunningPolicy runningPolicy) { - job->setParent(this); // Protects from #397, #398 + // Reparent to protect from #397, #398 and to prevent BaseJob* from being + // garbage-collected if made by or returned to QML/JavaScript. + job->setParent(this); connect(job, &BaseJob::failure, this, &Connection::requestFailed); job->initiate(d->data.get(), runningPolicy & BackgroundRequest); + return job; } void Connection::getTurnServers() diff --git a/lib/connection.h b/lib/connection.h index 7998afa8..12b0756d 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -422,7 +422,8 @@ public: void setLazyLoading(bool newValue); /*! Start a pre-created job object on this connection */ - void run(BaseJob* job, RunningPolicy runningPolicy = ForegroundRequest); + Q_INVOKABLE BaseJob* run(BaseJob* job, + RunningPolicy runningPolicy = ForegroundRequest); /*! Start a job of a specified type with specified arguments and policy * |