mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +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(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");
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ public:
|
|||
const QString _remoteFolder; // folder. (same as remoteDir but without remote.php/webdav)
|
||||
|
||||
SyncJournalDb * const _journal;
|
||||
bool _finishedEmited; // used to ensure that finished is only emit once
|
||||
|
||||
public:
|
||||
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+'/' )
|
||||
, _remoteFolder((remoteFolder.endsWith(QChar('/'))) ? remoteFolder : remoteFolder+'/' )
|
||||
, _journal(progressDb)
|
||||
, _finishedEmited(false)
|
||||
, _activeJobs(0)
|
||||
{ }
|
||||
|
||||
|
@ -218,12 +220,21 @@ public:
|
|||
if (_rootJob) {
|
||||
_rootJob->abort();
|
||||
}
|
||||
emit finished();
|
||||
emitFinished();
|
||||
}
|
||||
|
||||
// timeout in seconds
|
||||
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:
|
||||
void completed(const SyncFileItem &);
|
||||
void progress(const SyncFileItem&, quint64 bytes);
|
||||
|
|
Loading…
Reference in a new issue