diff --git a/synfig-core/src/modules/lyr_freetype/lyr_freetype.cpp b/synfig-core/src/modules/lyr_freetype/lyr_freetype.cpp index 1893f0b..49eee8b 100644 --- a/synfig-core/src/modules/lyr_freetype/lyr_freetype.cpp +++ b/synfig-core/src/modules/lyr_freetype/lyr_freetype.cpp @@ -481,7 +481,7 @@ Layer_Freetype::new_face(const String &newfont) bool Layer_Freetype::set_param(const String & param, const ValueBase &value) { - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); /* if(param=="font" && value.same_type_as(font)) { @@ -715,7 +715,7 @@ Layer_Freetype::accelerated_render(Context context,Surface *surface,int quality, synfig::Point origin=param_origin.get(Point()); synfig::Vector orient=param_orient.get(Vector()); - static synfig::RecMutex freetype_mutex; + static std::recursive_mutex freetype_mutex; if(needs_sync_) const_cast(this)->sync(); @@ -762,7 +762,7 @@ Layer_Freetype::accelerated_render(Context context,Surface *surface,int quality, return true; } - synfig::RecMutex::Lock lock(freetype_mutex); + std::lock_guard lock(freetype_mutex); #define CHAR_RESOLUTION (64) error = FT_Set_Char_Size( diff --git a/synfig-core/src/modules/lyr_freetype/lyr_freetype.h b/synfig-core/src/modules/lyr_freetype/lyr_freetype.h index 9b94688..bc9e4c3 100644 --- a/synfig-core/src/modules/lyr_freetype/lyr_freetype.h +++ b/synfig-core/src/modules/lyr_freetype/lyr_freetype.h @@ -150,7 +150,7 @@ private: synfig::Color color_func(const synfig::Point &x, int quality=10, synfig::ColorReal supersample=0)const; - mutable synfig::Mutex mutex; + mutable std::mutex mutex_; public: Layer_Freetype(); diff --git a/synfig-core/src/modules/mod_particle/plant.cpp b/synfig-core/src/modules/mod_particle/plant.cpp index d8066c4..7221d48 100644 --- a/synfig-core/src/modules/mod_particle/plant.cpp +++ b/synfig-core/src/modules/mod_particle/plant.cpp @@ -223,7 +223,7 @@ Plant::sync()const int splits=param_splits.get(int()); bool use_width=param_use_width.get(bool()); - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); if (!needs_sync_) return; time_t start_time; time(&start_time); particle_list.clear(); diff --git a/synfig-core/src/modules/mod_particle/plant.h b/synfig-core/src/modules/mod_particle/plant.h index ce4af45..08db880 100644 --- a/synfig-core/src/modules/mod_particle/plant.h +++ b/synfig-core/src/modules/mod_particle/plant.h @@ -104,7 +104,7 @@ private: Real mass; mutable bool needs_sync_; - mutable Mutex mutex; + mutable mutex mutex_; void branch(int n, int depth,float t, float stunt_growth, Point position,Vector velocity)const; void sync()const; diff --git a/synfig-core/src/synfig/debug/log.cpp b/synfig-core/src/synfig/debug/log.cpp index a24c380..33cde88 100644 --- a/synfig-core/src/synfig/debug/log.cpp +++ b/synfig-core/src/synfig/debug/log.cpp @@ -53,11 +53,11 @@ using namespace debug; /* === M E T H O D S ======================================================= */ -Mutex Log::mutex; +std::mutex Log::mutex_; void Log::append_line_to_file(const String &logfile, const String &str) { - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); std::ofstream f(logfile.c_str(), std::ios_base::app); f << str << std::endl; } diff --git a/synfig-core/src/synfig/debug/log.h b/synfig-core/src/synfig/debug/log.h index 1415d3e..272172b 100644 --- a/synfig-core/src/synfig/debug/log.h +++ b/synfig-core/src/synfig/debug/log.h @@ -28,8 +28,8 @@ /* === H E A D E R S ======================================================= */ #include -#include #include +#include /* === M A C R O S ========================================================= */ @@ -44,7 +44,7 @@ namespace debug { class Log { private: - static Mutex mutex; + static std::mutex mutex_; public: diff --git a/synfig-core/src/synfig/layers/layer_bitmap.cpp b/synfig-core/src/synfig/layers/layer_bitmap.cpp index e90f46b..d8b0fae 100644 --- a/synfig-core/src/synfig/layers/layer_bitmap.cpp +++ b/synfig-core/src/synfig/layers/layer_bitmap.cpp @@ -257,7 +257,7 @@ synfig::Layer_Bitmap::get_color(Context context, const Point &pos)const surface_pos[1]/=br[1]-tl[1]; if(surface_pos[1]<=1.0 && surface_pos[1]>=0.0) { - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); if (trimmed) { @@ -364,7 +364,7 @@ Layer_Bitmap::accelerated_render(Context context,Surface *surface,int quality, c { RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__) - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); Point tl(param_tl.get(Point())); Point br(param_br.get(Point())); diff --git a/synfig-core/src/synfig/layers/layer_bitmap.h b/synfig-core/src/synfig/layers/layer_bitmap.h index 6e78820..ff98b7a 100644 --- a/synfig-core/src/synfig/layers/layer_bitmap.h +++ b/synfig-core/src/synfig/layers/layer_bitmap.h @@ -60,7 +60,7 @@ public: ValueBase param_c; ValueBase param_gamma_adjust; - mutable synfig::Mutex mutex; + mutable std::mutex mutex_; mutable rendering::software::PackedSurface::Reader reader; mutable rendering::SurfaceResource::Handle rendering_surface; mutable bool trimmed; diff --git a/synfig-core/src/synfig/layers/layer_duplicate.cpp b/synfig-core/src/synfig/layers/layer_duplicate.cpp index 08786c5..251f8a2 100644 --- a/synfig-core/src/synfig/layers/layer_duplicate.cpp +++ b/synfig-core/src/synfig/layers/layer_duplicate.cpp @@ -121,7 +121,7 @@ Layer_Duplicate::get_color(Context context, const Point &pos)const float amount(get_amount()); Color color; - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); Time time_cur = get_time_mark(); duplicate_param->reset_index(time_cur); do @@ -187,7 +187,7 @@ Layer_Duplicate::accelerated_render(Context context,Surface *surface,int quality Time time_cur = get_time_mark(); int steps = duplicate_param->count_steps(time_cur); - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); duplicate_param->reset_index(time_cur); do { @@ -233,7 +233,7 @@ Layer_Duplicate::accelerated_cairorender(Context context, cairo_t *cr, int quali Time time_cur = get_time_mark(); int steps = duplicate_param->count_steps(time_cur); - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); duplicate_param->reset_index(time_cur); cairo_save(cr); do @@ -269,7 +269,7 @@ Layer_Duplicate::build_rendering_task_vfunc(Context context) const rendering::Task::Handle task; - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); duplicate_param->reset_index(time_cur); do { diff --git a/synfig-core/src/synfig/layers/layer_duplicate.h b/synfig-core/src/synfig/layers/layer_duplicate.h index b2d0944..15caeff 100644 --- a/synfig-core/src/synfig/layers/layer_duplicate.h +++ b/synfig-core/src/synfig/layers/layer_duplicate.h @@ -42,7 +42,7 @@ class Layer_Duplicate : public synfig::Layer_CompositeFork private: mutable ValueBase param_index; - mutable synfig::Mutex mutex; + mutable std::mutex mutex_; public: diff --git a/synfig-core/src/synfig/main.cpp b/synfig-core/src/synfig/main.cpp index e33a2e9..498e4ac 100644 --- a/synfig-core/src/synfig/main.cpp +++ b/synfig-core/src/synfig/main.cpp @@ -103,13 +103,13 @@ Main *Main::instance = NULL; class GeneralIOMutexHolder { private: - Mutex mutex; + mutex mutex_; bool initialized; public: GeneralIOMutexHolder(): initialized(true) { } ~GeneralIOMutexHolder() { initialized = false; } - void lock() { if (initialized) mutex.lock(); } - void unlock() { if (initialized) mutex.unlock(); } + void lock() { if (initialized) mutex_.lock(); } + void unlock() { if (initialized) mutex_.unlock(); } }; GeneralIOMutexHolder general_io_mutex; diff --git a/synfig-core/src/synfig/mutex.cpp b/synfig-core/src/synfig/mutex.cpp index c35bd26..9dee831 100644 --- a/synfig-core/src/synfig/mutex.cpp +++ b/synfig-core/src/synfig/mutex.cpp @@ -65,96 +65,7 @@ using namespace synfig; /* === M E T H O D S ======================================================= */ - - - - - -bool -Mutex::is_locked() -{ - if(try_lock()) - { - unlock(); - return false; - } - return true; -} - -void -RecMutex::unlock_all() -{ - while(is_locked()) unlock(); -} - #ifdef USING_PTHREADS -Mutex::Mutex() -{ - pthread_mutex_t*const mtx_ptr(new pthread_mutex_t); - - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - - //#ifdef PTHREAD_PRIO_INHERIT - //pthread_mutexattr_setprioceiling(&attr,PTHREAD_PRIO_INHERIT); - //#endif - - //#ifdef PTHREAD_MUTEX_RECURSIVE - //pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE); - //#endif - - pthread_mutex_init(mtx_ptr,&attr); - pthread_mutexattr_destroy(&attr); - - blackbox=mtx_ptr; -} - -Mutex::~Mutex() -{ - pthread_mutex_t*const mtx_ptr(static_cast(blackbox)); - pthread_mutex_destroy(mtx_ptr); - delete mtx_ptr; -} - -void -Mutex::lock() -{ - pthread_mutex_t*const mtx_ptr(static_cast(blackbox)); - pthread_mutex_lock(mtx_ptr); -} - -void -Mutex::unlock() -{ - pthread_mutex_t*const mtx_ptr(static_cast(blackbox)); - pthread_mutex_unlock(mtx_ptr); -} - -bool -Mutex::try_lock() -{ - pthread_mutex_t*const mtx_ptr(static_cast(blackbox)); - return !(bool) pthread_mutex_trylock(mtx_ptr); -} - - -RecMutex::RecMutex() -{ - pthread_mutex_t*const mtx_ptr(static_cast(blackbox)); - pthread_mutexattr_t attr; - - // Backtrack and get rid of the non-recursive mutex - pthread_mutex_destroy(mtx_ptr); - - pthread_mutexattr_init(&attr); - - pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE); - - pthread_mutex_init(mtx_ptr,&attr); - pthread_mutexattr_destroy(&attr); -} - - RWLock::RWLock() { @@ -225,45 +136,6 @@ RWLock::writer_trylock() #endif #ifdef USING_WIN32_THREADS -Mutex::Mutex() -{ - HANDLE& mtx(*reinterpret_cast(&blackbox)); - mtx=CreateMutex(NULL, FALSE, NULL); -} - -Mutex::~Mutex() -{ - HANDLE mtx(reinterpret_cast(blackbox)); - CloseHandle(mtx); -} - -void -Mutex::lock() -{ - HANDLE mtx(reinterpret_cast(blackbox)); - WaitForSingleObject(mtx, INFINITE); -} - -void -Mutex::unlock() -{ - HANDLE mtx(reinterpret_cast(blackbox)); - ReleaseMutex(mtx); -} - -bool -Mutex::try_lock() -{ - HANDLE mtx(reinterpret_cast(blackbox)); - return WaitForSingleObject(mtx, 0)==WAIT_FAILED; -} - - -RecMutex::RecMutex() -{ - // Win32 mutexes are recursive by default. -} - RWLock::RWLock() { diff --git a/synfig-core/src/synfig/mutex.h b/synfig-core/src/synfig/mutex.h index 3497635..d0ab6e7 100644 --- a/synfig-core/src/synfig/mutex.h +++ b/synfig-core/src/synfig/mutex.h @@ -35,49 +35,6 @@ namespace synfig { -class RecMutex; - -class Mutex -{ - friend class RecMutex; - -protected: - void* blackbox; - -public: - - class Lock - { - Mutex& mutex; - public: - Lock(Mutex& x):mutex(x) { mutex.lock(); } - ~Lock() { mutex.unlock(); } - }; - - Mutex(); - ~Mutex(); - - void lock(); - void unlock(); - bool try_lock(); - bool is_locked(); - -private: - //! Non-copyable - Mutex(const Mutex&); - - //! Non-assignable - void operator=(const Mutex&); -}; - -class RecMutex : public Mutex -{ -public: - RecMutex(); - - void unlock_all(); -}; - class RWLock { void* blackbox; diff --git a/synfig-core/src/synfig/node.cpp b/synfig-core/src/synfig/node.cpp index a66caf1..201f8fa 100644 --- a/synfig-core/src/synfig/node.cpp +++ b/synfig-core/src/synfig/node.cpp @@ -72,21 +72,21 @@ namespace { typedef std::map Map; private: - Mutex mutex; + std::mutex mutex_; Map map; public: Node* get(const GUID &guid) { - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); Map::iterator i = map.find(guid); - return i == map.end() ? 0 : i->second; + return i == map.end() ? nullptr : i->second; } void add(const GUID &guid, Node *node) { assert(guid); assert(node); - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); assert(!map.count(guid)); map[guid] = node; } @@ -95,7 +95,7 @@ namespace { assert(guid); assert(node); - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); Map::iterator i = map.find(guid); assert(i != map.end() && i->second == node); map.erase(i); @@ -110,7 +110,7 @@ namespace { } assert(oldguid); - Mutex::Lock lock(mutex); + std::lock_guard lock(mutex_); Map::iterator i = map.find(oldguid); assert(i != map.end() && i->second == node); map.erase(i); @@ -218,7 +218,7 @@ Node::child_changed(const Node *x) const synfig::GUID& Node::get_guid()const { - Mutex::Lock lock(guid_mutex_); + std::lock_guard lock(guid_mutex_); if(!guid_) { guid_.make_unique(); @@ -232,7 +232,7 @@ void Node::set_guid(const synfig::GUID& x) { assert(x); - Mutex::Lock lock(guid_mutex_); + std::lock_guard lock(guid_mutex_); if (guid_ == x) return; if (!guid_) { diff --git a/synfig-core/src/synfig/node.h b/synfig-core/src/synfig/node.h index 4fb0133..3efe400 100644 --- a/synfig-core/src/synfig/node.h +++ b/synfig-core/src/synfig/node.h @@ -37,6 +37,7 @@ #include "guid.h" #include #include "interpolation.h" +#include #include "mutex.h" /* === M A C R O S ========================================================= */ @@ -141,7 +142,7 @@ public: private: //! \ The GUID of the node - mutable Mutex guid_mutex_; + mutable std::mutex guid_mutex_; mutable GUID guid_; //! cached time values for all the children diff --git a/synfig-core/src/synfig/rendering/primitive/contour.cpp b/synfig-core/src/synfig/rendering/primitive/contour.cpp index 633727d..a9afd2c 100644 --- a/synfig-core/src/synfig/rendering/primitive/contour.cpp +++ b/synfig-core/src/synfig/rendering/primitive/contour.cpp @@ -453,12 +453,12 @@ Contour::assign(const Contour &other) // other contour is constant, so we need to lock mutexes for read the bounds and intersector // see comments for get_bounds() and get_intersector() declarations { - Mutex::Lock lock(other.bounds_read_mutex); + std::lock_guard lock(other.bounds_read_mutex); bounds_calculated = other.bounds_calculated; bounds = other.bounds; } { - Mutex::Lock lock(other.intersector_read_mutex); + std::lock_guard lock(other.intersector_read_mutex); intersector = other.intersector; } } @@ -585,7 +585,7 @@ Contour::calc_bounds(const Matrix &transform_matrix) const Rect Contour::get_bounds() const { - Mutex::Lock lock(bounds_read_mutex); + std::lock_guard lock(bounds_read_mutex); if (!bounds_calculated) { bounds = calc_bounds(); bounds_calculated = true; @@ -621,10 +621,10 @@ Contour::crerate_intersector() const const Intersector& Contour::get_intersector() const { - Mutex::Lock lock(intersector_read_mutex); + std::lock_guard lock(intersector_read_mutex); if (!intersector) { intersector = crerate_intersector(); - Mutex::Lock lock(bounds_read_mutex); + std::lock_guard lock(bounds_read_mutex); if (!bounds_calculated) { bounds = intersector->get_bounds(); bounds_calculated = true; diff --git a/synfig-core/src/synfig/rendering/primitive/contour.h b/synfig-core/src/synfig/rendering/primitive/contour.h index 356206f..4f2f5e3 100644 --- a/synfig-core/src/synfig/rendering/primitive/contour.h +++ b/synfig-core/src/synfig/rendering/primitive/contour.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include /* === M A C R O S ========================================================= */ @@ -102,11 +102,11 @@ private: int first; bool autocurve_begin, autocurve_end; - mutable Mutex bounds_read_mutex; + mutable std::mutex bounds_read_mutex; mutable bool bounds_calculated; mutable Rect bounds; - mutable Mutex intersector_read_mutex; + mutable std::mutex intersector_read_mutex; mutable etl::handle intersector; //! call this when 'chunks' or 'first' was changed diff --git a/synfig-core/src/synfig/rendering/primitive/mesh.cpp b/synfig-core/src/synfig/rendering/primitive/mesh.cpp index 7493f11..e953ab2 100644 --- a/synfig-core/src/synfig/rendering/primitive/mesh.cpp +++ b/synfig-core/src/synfig/rendering/primitive/mesh.cpp @@ -55,7 +55,7 @@ Mesh::assign(const Mesh &other) { // other mesh is constant, so we need to lock mutexes for read the relolution data // see comment for calculate_resolution_transfrom() declaration { - Mutex::Lock lock(other.resolution_transfrom_read_mutex); + std::lock_guard lock(other.resolution_transfrom_read_mutex); resolution_transfrom_calculated = other.resolution_transfrom_calculated; target_rectangle = other.target_rectangle; source_rectangle = other.source_rectangle; @@ -130,14 +130,14 @@ Mesh::calculate_resolution_transfrom_no_lock(bool force) const void Mesh::calculate_resolution_transfrom(bool force) const { - Mutex::Lock lock(resolution_transfrom_read_mutex); + std::lock_guard lock(resolution_transfrom_read_mutex); calculate_resolution_transfrom_no_lock(force); } Matrix2 Mesh::get_resolution_transfrom() const { - Mutex::Lock lock(resolution_transfrom_read_mutex); + std::lock_guard lock(resolution_transfrom_read_mutex); calculate_resolution_transfrom_no_lock(); return resolution_transfrom; } @@ -145,7 +145,7 @@ Mesh::get_resolution_transfrom() const Rect Mesh::get_target_rectangle() const { - Mutex::Lock lock(resolution_transfrom_read_mutex); + std::lock_guard lock(resolution_transfrom_read_mutex); calculate_resolution_transfrom_no_lock(); return target_rectangle; } @@ -153,7 +153,7 @@ Mesh::get_target_rectangle() const Rect Mesh::get_source_rectangle() const { - Mutex::Lock lock(resolution_transfrom_read_mutex); + std::lock_guard lock(resolution_transfrom_read_mutex); calculate_resolution_transfrom_no_lock(); return source_rectangle; } diff --git a/synfig-core/src/synfig/rendering/primitive/mesh.h b/synfig-core/src/synfig/rendering/primitive/mesh.h index eeaddaf..87feeb2 100644 --- a/synfig-core/src/synfig/rendering/primitive/mesh.h +++ b/synfig-core/src/synfig/rendering/primitive/mesh.h @@ -35,7 +35,7 @@ #include #include -#include +#include /* === M A C R O S ========================================================= */ @@ -78,7 +78,7 @@ public: TriangleList triangles; private: - mutable Mutex resolution_transfrom_read_mutex; + mutable std::mutex resolution_transfrom_read_mutex; mutable bool resolution_transfrom_calculated; mutable Rect target_rectangle; mutable Rect source_rectangle; diff --git a/synfig-core/src/synfig/rendering/software/function/packedsurface.cpp b/synfig-core/src/synfig/rendering/software/function/packedsurface.cpp index ac78039..11de59e 100644 --- a/synfig-core/src/synfig/rendering/software/function/packedsurface.cpp +++ b/synfig-core/src/synfig/rendering/software/function/packedsurface.cpp @@ -89,7 +89,7 @@ PackedSurface::Reader::open(const PackedSurface &surface) { this->surface = &surface; - synfig::Mutex::Lock lock(surface.mutex); + std::lock_guard lock(surface.mutex_); surface.readers.insert(this); } @@ -120,7 +120,7 @@ PackedSurface::Reader::close() if (is_opened()) { { - synfig::Mutex::Lock lock(surface->mutex); + std::lock_guard lock(surface->mutex_); surface->readers.erase(this); } if (cache) delete[] cache; diff --git a/synfig-core/src/synfig/rendering/software/function/packedsurface.h b/synfig-core/src/synfig/rendering/software/function/packedsurface.h index 8eb85e7..9d69653 100644 --- a/synfig-core/src/synfig/rendering/software/function/packedsurface.h +++ b/synfig-core/src/synfig/rendering/software/function/packedsurface.h @@ -129,7 +129,7 @@ public: typedef etl::sampler Sampler; private: - mutable synfig::Mutex mutex; + mutable std::mutex mutex_; mutable std::set readers; int width; diff --git a/synfig-studio/src/gui/ipc.cpp b/synfig-studio/src/gui/ipc.cpp index 5f554b6..668aa79 100644 --- a/synfig-studio/src/gui/ipc.cpp +++ b/synfig-studio/src/gui/ipc.cpp @@ -61,12 +61,11 @@ #include "docks/dock_toolbox.h" #include -#include +#include +#include #include #include -#include #include - #ifdef _WIN32 #include #define BUFSIZE 128 @@ -90,7 +89,7 @@ using namespace studio; #ifdef _WIN32 #define WIN32_PIPE_PATH "\\\\.\\pipe\\SynfigStudio.Cmd" -static synfig::Mutex cmd_mutex; +static std::mutex cmd_mutex; static std::list cmd_queue; static Glib::Dispatcher* cmd_dispatcher; static void @@ -120,7 +119,7 @@ pipe_listen_thread() DWORD read_bytes; bool success; - Glib::Thread::yield(); + std::this_thread::yield(); if(connected) do { @@ -138,7 +137,7 @@ pipe_listen_thread() if(success && read_bytes==1 && c!='\n') data+=c; }while(c!='\n'); - synfig::Mutex::Lock lock(cmd_mutex); + std::lock_guard lock(cmd_mutex); cmd_queue.push_back(data); cmd_dispatcher->emit(); } while(success && read_bytes); @@ -150,7 +149,7 @@ pipe_listen_thread() static void empty_cmd_queue() { - synfig::Mutex::Lock lock(cmd_mutex); + std::lock_guard lock(cmd_mutex); while(!cmd_queue.empty()) { IPC::process_command(cmd_queue.front()); @@ -171,7 +170,7 @@ IPC::IPC() cmd_dispatcher=new Glib::Dispatcher; cmd_dispatcher->connect(sigc::ptr_fun(empty_cmd_queue)); - Glib::Thread::create( + new std::thread( sigc::ptr_fun(pipe_listen_thread), false ); diff --git a/synfig-studio/src/synfigapp/actions/layerpaint.cpp b/synfig-studio/src/synfigapp/actions/layerpaint.cpp index 7dd761a..b44fd25 100644 --- a/synfig-studio/src/synfigapp/actions/layerpaint.cpp +++ b/synfig-studio/src/synfigapp/actions/layerpaint.cpp @@ -154,7 +154,7 @@ Action::LayerPaint::PaintStroke::add_point_and_apply(const PaintPoint &point) int w = wrapper.surface->get_w(); int h = wrapper.surface->get_h(); { - Mutex::Lock lock(layer->mutex); + std::lock_guard lock(layer->mutex_); brush_.stroke_to(&wrapper, point.x, point.y, point.pressure, 0.f, 0.f, point.dtime); // fix state in case of surface resized @@ -219,7 +219,7 @@ Action::LayerPaint::PaintStroke::undo() assert(prepared); if (!applied) return; { - Mutex::Lock lock(layer->mutex); + std::lock_guard lock(layer->mutex_); Surface *surface = new Surface(); paint_prev(*surface); layer->rendering_surface = new rendering::SurfaceResource( @@ -237,7 +237,7 @@ Action::LayerPaint::PaintStroke::apply() assert(prepared); if (applied) return; { - Mutex::Lock lock(layer->mutex); + std::lock_guard lock(layer->mutex_); Surface *surface = new Surface(); paint_self(*surface); layer->rendering_surface = new rendering::SurfaceResource(