Fix some extra issues reported by the ThreadSanitizer

This commit is contained in:
David Capello 2020-06-17 18:10:26 -03:00
parent 6f048d10c5
commit 319733d30b
6 changed files with 12 additions and 7 deletions

2
laf

@ -1 +1 @@
Subproject commit 0dd4ba1bdd910fb00d2e209d8c3b4454a09ce271 Subproject commit 85a17a563197ab8ec14ad43a727ab10173439f83

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019 Igara Studio S.A. // Copyright (C) 2019-2020 Igara Studio S.A.
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
@ -10,6 +10,7 @@
#include "base/time.h" #include "base/time.h"
#include <atomic>
#include <condition_variable> #include <condition_variable>
#include <mutex> #include <mutex>
#include <thread> #include <thread>
@ -49,7 +50,7 @@ namespace app {
base::tick_t timestamp; base::tick_t timestamp;
}; };
bool m_done; std::atomic<bool> m_done;
base::tick_t m_dataRecoveryPeriodMSecs; base::tick_t m_dataRecoveryPeriodMSecs;
base::tick_t m_keepClosedDocAliveForMSecs; base::tick_t m_keepClosedDocAliveForMSecs;
std::vector<ClosedDoc> m_docs; std::vector<ClosedDoc> m_docs;

View File

@ -110,6 +110,8 @@ void BackupObserver::onRemoveDocument(Doc* doc)
// then it's deleted from ClosedDocs::backgroundThread() // then it's deleted from ClosedDocs::backgroundThread()
TRACE("RECO: Adding to CLOSEDOC %p\n", doc); TRACE("RECO: Adding to CLOSEDOC %p\n", doc);
std::unique_lock<std::mutex> lock(m_mutex);
m_closedDocs.push_back(doc); m_closedDocs.push_back(doc);
} }
else { else {

View File

@ -125,7 +125,7 @@ void Doc::unlock()
m_rwLock.unlock(); m_rwLock.unlock();
} }
bool Doc::weakLock(base::RWLock::WeakLock* weak_lock_flag) bool Doc::weakLock(std::atomic<base::RWLock::WeakLock>* weak_lock_flag)
{ {
return m_rwLock.weakLock(weak_lock_flag); return m_rwLock.weakLock(weak_lock_flag);
} }

View File

@ -26,6 +26,7 @@
#include "obs/observable.h" #include "obs/observable.h"
#include "os/color_space.h" #include "os/color_space.h"
#include <atomic>
#include <memory> #include <memory>
#include <string> #include <string>
@ -79,7 +80,7 @@ namespace app {
void downgradeToRead(); void downgradeToRead();
void unlock(); void unlock();
bool weakLock(base::RWLock::WeakLock* weak_lock_flag); bool weakLock(std::atomic<base::RWLock::WeakLock>* weak_lock_flag);
void weakUnlock(); void weakUnlock();
// Sets active/running transaction. // Sets active/running transaction.

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019 Igara Studio S.A. // Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -13,6 +13,7 @@
#include "app/doc.h" #include "app/doc.h"
#include "base/exception.h" #include "base/exception.h"
#include <atomic>
#include <exception> #include <exception>
namespace app { namespace app {
@ -245,7 +246,7 @@ namespace app {
WeakDocReader(const WeakDocReader&); WeakDocReader(const WeakDocReader&);
WeakDocReader& operator=(const WeakDocReader&); WeakDocReader& operator=(const WeakDocReader&);
base::RWLock::WeakLock m_weak_lock; std::atomic<base::RWLock::WeakLock> m_weak_lock;
}; };
} // namespace app } // namespace app