From 08cc50a3e6699e4d0cff60108260adbd8cbdf419 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 30 Mar 2020 19:41:59 +0200 Subject: Connection::resolveServer(): reparent jobs to ensure proper clean-away This is a spot fix for #398; Quotient 0.6 will reparent all jobs to make sure they are removed after the connection is gone (this also partially helps with #397). --- lib/connection.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/connection.cpp') diff --git a/lib/connection.cpp b/lib/connection.cpp index cc140ae4..0c98c383 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -185,6 +185,10 @@ void Connection::resolveServer(const QString& mxidOrDomain) d->data->setBaseUrl(maybeBaseUrl); // Just enough to check .well-known file auto getWellKnownJob = callApi(); + // This is a workaround for 0.5.x; due to the way Quaternion's login dialog + // operates, Connection can disappear any moment during server resolution. + // Quotient 0.6 will reparent all jobs to enforce lifetimes. See also #398. + getWellKnownJob->setParent(this); connect(getWellKnownJob, &BaseJob::finished, this, [this, getWellKnownJob, maybeBaseUrl] { if (getWellKnownJob->status() != BaseJob::NotFoundError) { @@ -216,6 +220,7 @@ void Connection::resolveServer(const QString& mxidOrDomain) } auto getVersionsJob = callApi(); + getVersionsJob->setParent(this); // Same workaround as above connect(getVersionsJob, &BaseJob::success, this, &Connection::resolved); connect(getVersionsJob, &BaseJob::failure, this, [this] { -- cgit v1.2.3