diff --git a/lib/brush.hpp b/lib/brush.hpp index fcf423250..dbb4ffc7c 100644 --- a/lib/brush.hpp +++ b/lib/brush.hpp @@ -66,8 +66,12 @@ class Brush { bool stroke_to (Surface * surface, float x, float y, float pressure, float xtilt, float ytilt, double dtime, float viewzoom, float viewrotation, float barrel_rotation, bool linear) { MyPaintSurface *c_surface = surface->get_surface_interface(); - bool retval = mypaint_brush_stroke_to(c_brush, c_surface, x, y, pressure, xtilt, ytilt, dtime, viewzoom, viewrotation, barrel_rotation, linear); - return retval; + bool stroke_finished_or_empty; + + Py_BEGIN_ALLOW_THREADS + stroke_finished_or_empty = mypaint_brush_stroke_to(c_brush, c_surface, x, y, pressure, xtilt, ytilt, dtime, viewzoom, viewrotation, barrel_rotation, linear); + Py_END_ALLOW_THREADS + return stroke_finished_or_empty; } double get_total_stroke_painting_time() diff --git a/lib/pythontiledsurface.cpp b/lib/pythontiledsurface.cpp index 5a009e476..517dcf31c 100644 --- a/lib/pythontiledsurface.cpp +++ b/lib/pythontiledsurface.cpp @@ -36,8 +36,9 @@ tile_request_start(MyPaintTiledSurface *tiled_surface, MyPaintTileRequest *reque const int ty = request->ty; PyArrayObject* rgba = NULL; -#pragma omp critical { + PyGILState_STATE gstate = PyGILState_Ensure(); + rgba = (PyArrayObject*)PyObject_CallMethod(self->py_obj, "_get_tile_numpy", "(iii)", tx, ty, readonly); if (rgba == NULL) { request->buffer = NULL; @@ -59,7 +60,9 @@ tile_request_start(MyPaintTiledSurface *tiled_surface, MyPaintTileRequest *reque Py_DECREF((PyObject *)rgba); request->buffer = (uint16_t*)PyArray_DATA(rgba); } -} // #end pragma opt critical + + PyGILState_Release(gstate); +} } diff --git a/lib/tiledsurface.hpp b/lib/tiledsurface.hpp index 96b98bfa3..315f0d9b7 100644 --- a/lib/tiledsurface.hpp +++ b/lib/tiledsurface.hpp @@ -69,7 +69,9 @@ class TiledSurface : public Surface { MyPaintRectangle* rects = this->bbox_rectangles; MyPaintRectangles bboxes = {BBOXES, rects}; - mypaint_surface_end_atomic((MyPaintSurface *)c_surface, &bboxes); + Py_BEGIN_ALLOW_THREADS + mypaint_surface_end_atomic((MyPaintSurface *)c_surface, &bboxes); + Py_END_ALLOW_THREADS // The capacity of the bounding box array will most often exceed the number // of rectangles that are actually used. The call to mypaint_surface_end_atomic