mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Make sure that OwncloudPropgator::finished is only emit once
When we abort, each job currently running may result in a call to finished(). It used to cause a crash because we would unlock the _syncMutex twice Fixes #1793
This commit is contained in:
parent
864f2cdc7d
commit
0151682a53
2 changed files with 13 additions and 2 deletions
|
@ -251,7 +251,7 @@ void OwncloudPropagator::start(const SyncFileItemVector& _syncedItems)
|
||||||
|
|
||||||
connect(_rootJob.data(), SIGNAL(completed(SyncFileItem)), this, SIGNAL(completed(SyncFileItem)));
|
connect(_rootJob.data(), SIGNAL(completed(SyncFileItem)), this, SIGNAL(completed(SyncFileItem)));
|
||||||
connect(_rootJob.data(), SIGNAL(progress(SyncFileItem,quint64)), this, SIGNAL(progress(SyncFileItem,quint64)));
|
connect(_rootJob.data(), SIGNAL(progress(SyncFileItem,quint64)), this, SIGNAL(progress(SyncFileItem,quint64)));
|
||||||
connect(_rootJob.data(), SIGNAL(finished(SyncFileItem::Status)), this, SIGNAL(finished()));
|
connect(_rootJob.data(), SIGNAL(finished(SyncFileItem::Status)), this, SLOT(emitFinished()));
|
||||||
|
|
||||||
qDebug() << (useLegacyJobs() ? "Using legacy libneon/HTTP sequential code path" : "Using QNAM/HTTP parallel code path");
|
qDebug() << (useLegacyJobs() ? "Using legacy libneon/HTTP sequential code path" : "Using QNAM/HTTP parallel code path");
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,7 @@ public:
|
||||||
const QString _remoteFolder; // folder. (same as remoteDir but without remote.php/webdav)
|
const QString _remoteFolder; // folder. (same as remoteDir but without remote.php/webdav)
|
||||||
|
|
||||||
SyncJournalDb * const _journal;
|
SyncJournalDb * const _journal;
|
||||||
|
bool _finishedEmited; // used to ensure that finished is only emit once
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OwncloudPropagator(ne_session_s *session, const QString &localDir, const QString &remoteDir, const QString &remoteFolder,
|
OwncloudPropagator(ne_session_s *session, const QString &localDir, const QString &remoteDir, const QString &remoteFolder,
|
||||||
|
@ -197,6 +198,7 @@ public:
|
||||||
, _remoteDir((remoteDir.endsWith(QChar('/'))) ? remoteDir : remoteDir+'/' )
|
, _remoteDir((remoteDir.endsWith(QChar('/'))) ? remoteDir : remoteDir+'/' )
|
||||||
, _remoteFolder((remoteFolder.endsWith(QChar('/'))) ? remoteFolder : remoteFolder+'/' )
|
, _remoteFolder((remoteFolder.endsWith(QChar('/'))) ? remoteFolder : remoteFolder+'/' )
|
||||||
, _journal(progressDb)
|
, _journal(progressDb)
|
||||||
|
, _finishedEmited(false)
|
||||||
, _activeJobs(0)
|
, _activeJobs(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -218,12 +220,21 @@ public:
|
||||||
if (_rootJob) {
|
if (_rootJob) {
|
||||||
_rootJob->abort();
|
_rootJob->abort();
|
||||||
}
|
}
|
||||||
emit finished();
|
emitFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
// timeout in seconds
|
// timeout in seconds
|
||||||
static int httpTimeout();
|
static int httpTimeout();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
/** Emit the finished signal and make sure it is only emit once */
|
||||||
|
void emitFinished() {
|
||||||
|
if (!_finishedEmited)
|
||||||
|
emit finished();
|
||||||
|
_finishedEmited = true;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void completed(const SyncFileItem &);
|
void completed(const SyncFileItem &);
|
||||||
void progress(const SyncFileItem&, quint64 bytes);
|
void progress(const SyncFileItem&, quint64 bytes);
|
||||||
|
|
Loading…
Reference in a new issue