From 9f6447f4af5c169e2bf9b64d31d78eebfbba5627 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 20 May 2015 16:56:08 -0300 Subject: [PATCH] Fix app::Document::m_mutex leak --- src/app/document.cpp | 9 ++++----- src/app/document.h | 7 ++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/app/document.cpp b/src/app/document.cpp index e7b849c21..7d00cbe0f 100644 --- a/src/app/document.cpp +++ b/src/app/document.cpp @@ -46,7 +46,6 @@ using namespace doc; Document::Document(Sprite* sprite) : m_undo(new DocumentUndo) , m_associated_to_file(false) - , m_mutex(new mutex) , m_write_lock(false) , m_read_locks(0) // Information about the file format used to load/save this document @@ -515,7 +514,7 @@ bool Document::lock(LockType lockType, int timeout) { while (timeout >= 0) { { - scoped_lock lock(*m_mutex); + scoped_lock lock(m_mutex); switch (lockType) { case ReadLock: @@ -560,7 +559,7 @@ bool Document::lockToWrite(int timeout) { while (timeout >= 0) { { - scoped_lock lock(*m_mutex); + scoped_lock lock(m_mutex); // this only is possible if there are just one reader if (m_read_locks == 1) { ASSERT(!m_write_lock); @@ -589,7 +588,7 @@ bool Document::lockToWrite(int timeout) void Document::unlockToRead() { - scoped_lock lock(*m_mutex); + scoped_lock lock(m_mutex); ASSERT(m_read_locks == 0); ASSERT(m_write_lock); @@ -600,7 +599,7 @@ void Document::unlockToRead() void Document::unlock() { - scoped_lock lock(*m_mutex); + scoped_lock lock(m_mutex); if (m_write_lock) { m_write_lock = false; diff --git a/src/app/document.h b/src/app/document.h index 892b240db..700908019 100644 --- a/src/app/document.h +++ b/src/app/document.h @@ -11,6 +11,7 @@ #include "app/file/format_options.h" #include "base/disable_copying.h" +#include "base/mutex.h" #include "base/observable.h" #include "base/shared_ptr.h" #include "base/unique_ptr.h" @@ -25,10 +26,6 @@ #include -namespace base { - class mutex; -} - namespace doc { class Cel; class Layer; @@ -201,7 +198,7 @@ namespace app { } m_bound; // Mutex to modify the 'locked' flag. - base::mutex* m_mutex; + base::mutex m_mutex; // True if some thread is writing the sprite. bool m_write_lock;