Fix app::Document::m_mutex leak

This commit is contained in:
David Capello 2015-05-20 16:56:08 -03:00
parent ca16580b09
commit 9f6447f4af
2 changed files with 6 additions and 10 deletions

View File

@ -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;

View File

@ -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 <string>
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;