mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Add const to lock_guards
This commit is contained in:
parent
d37bfa6c43
commit
83d83cd8c6
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 3119ce537721992c5cbc3760ea6db7fa742702bb
|
||||
Subproject commit 12b411862df1655fac1f9c32847f1801c7205e2b
|
@ -151,7 +151,7 @@ void FilterWorker::run()
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
if (m_done && m_filterMgr->isTransaction())
|
||||
m_filterMgr->commitTransaction();
|
||||
else
|
||||
@ -180,7 +180,7 @@ void FilterWorker::run()
|
||||
//
|
||||
void FilterWorker::reportProgress(float progress)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
m_pos = progress;
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ bool FilterWorker::isCancelled()
|
||||
{
|
||||
bool cancelled;
|
||||
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
cancelled = (m_cancelled || m_abort);
|
||||
|
||||
return cancelled;
|
||||
@ -209,7 +209,7 @@ void FilterWorker::applyFilterInBackground()
|
||||
m_filterMgr->applyToTarget();
|
||||
|
||||
// Mark the work as 'done'.
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
m_done = true;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
@ -224,7 +224,7 @@ void FilterWorker::applyFilterInBackground()
|
||||
// every 100 milliseconds).
|
||||
void FilterWorker::onMonitoringTick()
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
|
||||
if (m_alert) {
|
||||
m_alert->setProgress(m_pos);
|
||||
|
@ -1122,13 +1122,13 @@ void FileOp::operate(IFileOpProgress* progress)
|
||||
void FileOp::done()
|
||||
{
|
||||
// Finally done.
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
m_done = true;
|
||||
}
|
||||
|
||||
void FileOp::stop()
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
if (!m_done)
|
||||
m_stop = true;
|
||||
}
|
||||
@ -1443,7 +1443,7 @@ void FileOp::setError(const char *format, ...)
|
||||
|
||||
// Concatenate the new error
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
// Add a newline char automatically if it's needed
|
||||
if (!m_error.empty() && m_error.back() != '\n')
|
||||
m_error.push_back('\n');
|
||||
@ -1455,7 +1455,7 @@ void FileOp::setIncompatibilityError(const std::string& msg)
|
||||
{
|
||||
// Concatenate the new error
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
// Add a newline char automatically if it's needed
|
||||
if (!m_incompatibilityError.empty() && m_incompatibilityError.back() != '\n')
|
||||
m_incompatibilityError.push_back('\n');
|
||||
@ -1465,7 +1465,7 @@ void FileOp::setIncompatibilityError(const std::string& msg)
|
||||
|
||||
void FileOp::setProgress(double progress)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
|
||||
if (isSequence()) {
|
||||
m_progress =
|
||||
@ -1494,7 +1494,7 @@ double FileOp::progress() const
|
||||
{
|
||||
double progress;
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
progress = m_progress;
|
||||
}
|
||||
return progress;
|
||||
@ -1506,7 +1506,7 @@ bool FileOp::isDone() const
|
||||
{
|
||||
bool done;
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
done = m_done;
|
||||
}
|
||||
return done;
|
||||
|
@ -29,7 +29,7 @@ Task::~Task()
|
||||
|
||||
void Task::run(base::task::func_t&& func)
|
||||
{
|
||||
std::lock_guard lock(m_token_mutex);
|
||||
const std::lock_guard lock(m_token_mutex);
|
||||
m_task.on_execute(std::move(func));
|
||||
m_token = &m_task.start(tasks_pool);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace app {
|
||||
}
|
||||
|
||||
bool canceled() const {
|
||||
std::lock_guard lock(m_token_mutex);
|
||||
const std::lock_guard lock(m_token_mutex);
|
||||
if (m_token)
|
||||
return m_token->canceled();
|
||||
else
|
||||
@ -42,7 +42,7 @@ namespace app {
|
||||
}
|
||||
|
||||
float progress() const {
|
||||
std::lock_guard lock(m_token_mutex);
|
||||
const std::lock_guard lock(m_token_mutex);
|
||||
if (m_token)
|
||||
return m_token->progress();
|
||||
else
|
||||
@ -50,13 +50,13 @@ namespace app {
|
||||
}
|
||||
|
||||
void cancel() {
|
||||
std::lock_guard lock(m_token_mutex);
|
||||
const std::lock_guard lock(m_token_mutex);
|
||||
if (m_token)
|
||||
m_token->cancel();
|
||||
}
|
||||
|
||||
void set_progress(float progress) {
|
||||
std::lock_guard lock(m_token_mutex);
|
||||
const std::lock_guard lock(m_token_mutex);
|
||||
if (m_token)
|
||||
m_token->set_progress(progress);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
~Worker() {
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
if (m_fop)
|
||||
m_fop->stop();
|
||||
}
|
||||
@ -57,7 +57,7 @@ public:
|
||||
}
|
||||
|
||||
void stop() const {
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
if (m_fop)
|
||||
m_fop->stop();
|
||||
}
|
||||
@ -67,7 +67,7 @@ public:
|
||||
}
|
||||
|
||||
void updateProgress() {
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
if (m_item.fileitem && m_item.fop) {
|
||||
double progress = m_item.fop->progress();
|
||||
if (progress > m_item.fileitem->getThumbnailProgress())
|
||||
@ -80,7 +80,7 @@ private:
|
||||
ASSERT(!m_fop);
|
||||
try {
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
m_fop = m_item.fop;
|
||||
ASSERT(m_fop);
|
||||
}
|
||||
@ -167,7 +167,7 @@ private:
|
||||
0, 0, 0, 0, thumbnailImage->width(), thumbnailImage->height());
|
||||
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
m_item.fileitem->setThumbnail(thumbnail);
|
||||
}
|
||||
}
|
||||
@ -191,13 +191,13 @@ private:
|
||||
// Reset the m_item (first the fileitem so this worker is not
|
||||
// associated to this fileitem anymore, and then the FileOp).
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
m_item.fileitem = nullptr;
|
||||
}
|
||||
|
||||
m_fop->done();
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
const std::lock_guard lock(m_mutex);
|
||||
m_item.fop = nullptr;
|
||||
delete m_fop;
|
||||
m_fop = nullptr;
|
||||
@ -212,7 +212,7 @@ private:
|
||||
bool success = true;
|
||||
while (success) {
|
||||
{
|
||||
std::lock_guard lock(m_mutex); // To access m_item
|
||||
const std::lock_guard lock(m_mutex); // To access m_item
|
||||
success = m_queue.try_pop(m_item);
|
||||
}
|
||||
if (success)
|
||||
@ -253,7 +253,7 @@ ThumbnailGenerator::ThumbnailGenerator()
|
||||
|
||||
bool ThumbnailGenerator::checkWorkers()
|
||||
{
|
||||
std::lock_guard lock(m_workersAccess);
|
||||
const std::lock_guard lock(m_workersAccess);
|
||||
bool doingWork = (!m_workers.empty());
|
||||
|
||||
for (WorkerList::iterator
|
||||
@ -339,14 +339,14 @@ void ThumbnailGenerator::stopAllWorkers()
|
||||
}
|
||||
}
|
||||
|
||||
std::lock_guard lock(m_workersAccess);
|
||||
const std::lock_guard lock(m_workersAccess);
|
||||
for (const auto& worker : m_workers)
|
||||
worker->stop();
|
||||
}
|
||||
|
||||
void ThumbnailGenerator::startWorker()
|
||||
{
|
||||
std::lock_guard lock(m_workersAccess);
|
||||
const std::lock_guard lock(m_workersAccess);
|
||||
if (m_workers.size() < m_maxWorkers) {
|
||||
m_workers.push_back(std::make_unique<Worker>(m_remainingItems));
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ const ObjectId Object::id() const
|
||||
// The first time the ID is request, we store the object in the
|
||||
// "objects" hash table.
|
||||
if (!m_id) {
|
||||
std::lock_guard lock(g_mutex);
|
||||
const std::lock_guard lock(g_mutex);
|
||||
m_id = ++newId;
|
||||
objects.insert(std::make_pair(m_id, const_cast<Object*>(this)));
|
||||
}
|
||||
@ -62,7 +62,7 @@ const ObjectId Object::id() const
|
||||
|
||||
void Object::setId(ObjectId id)
|
||||
{
|
||||
std::lock_guard lock(g_mutex);
|
||||
const std::lock_guard lock(g_mutex);
|
||||
|
||||
if (m_id) {
|
||||
auto it = objects.find(m_id);
|
||||
@ -101,7 +101,7 @@ void Object::setVersion(ObjectVersion version)
|
||||
|
||||
Object* get_object(ObjectId id)
|
||||
{
|
||||
std::lock_guard lock(g_mutex);
|
||||
const std::lock_guard lock(g_mutex);
|
||||
auto it = objects.find(id);
|
||||
if (it != objects.end())
|
||||
return it->second;
|
||||
|
Loading…
x
Reference in New Issue
Block a user