mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
06f26e85df
1. open LYX 2. CRTL-N 3. CRTL-D hold D --> crash Graph must be thread save to fix this. And for sure, we need a mutex also later. Mutex is a simple wrapper around QMutex, with pseudo-value semantic. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37222 a592a061-630c-0410-9148-cb99ea01b6c8
73 lines
914 B
C++
73 lines
914 B
C++
/**
|
|
* \file mutex.cpp
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Peter Kümmel
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "mutex.h"
|
|
|
|
#include <QMutex>
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
struct Mutex::Private
|
|
{
|
|
// QMutex::Recursive: less risks for dead-locks
|
|
Private() : qmutex_(QMutex::Recursive)
|
|
{
|
|
}
|
|
|
|
QMutex qmutex_;
|
|
};
|
|
|
|
|
|
Mutex::Mutex() : d(new Private)
|
|
{
|
|
}
|
|
|
|
|
|
Mutex::~Mutex()
|
|
{
|
|
delete d;
|
|
}
|
|
|
|
|
|
// It makes no sense to copy the mutex,
|
|
// each instance has its own QMutex,
|
|
// therefore nothing to copy!
|
|
// TODO review
|
|
Mutex::Mutex(const Mutex&) : d(new Private)
|
|
{
|
|
}
|
|
|
|
|
|
Mutex& Mutex::operator=(const Mutex&)
|
|
{
|
|
return *this;
|
|
}
|
|
|
|
|
|
|
|
Mutex::Locker::Locker(Mutex* mtx) : mutex_(mtx)
|
|
{
|
|
mutex_->d->qmutex_.lock();
|
|
}
|
|
|
|
|
|
Mutex::Locker::~Locker()
|
|
{
|
|
mutex_->d->qmutex_.unlock();
|
|
}
|
|
|
|
|
|
|
|
} // namespace lyx
|