diff options
-rw-r--r-- | vcl/inc/unx/gtk/gtkinst.hxx | 6 | ||||
-rw-r--r-- | vcl/unx/gtk/gtkinst.cxx | 16 |
2 files changed, 15 insertions, 7 deletions
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 86002fa7bf25..6212d5dcccba 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -20,6 +20,10 @@ #ifndef INCLUDED_VCL_INC_UNX_GTK_GTKINST_HXX #define INCLUDED_VCL_INC_UNX_GTK_GTKINST_HXX +#include <sal/config.h> + +#include <stack> + #include <unx/salinst.h> #include <unx/gensys.h> #include <headless/svpinst.hxx> @@ -42,7 +46,7 @@ class GtkPrintWrapper; class GenPspGraphics; class GtkYieldMutex : public SalYieldMutex { - thread_local static sal_uIntPtr yieldCount; + thread_local static std::stack<sal_uIntPtr> yieldCounts; public: GtkYieldMutex() {} diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx index a37102e0f30f..c138005a4c78 100644 --- a/vcl/unx/gtk/gtkinst.cxx +++ b/vcl/unx/gtk/gtkinst.cxx @@ -296,22 +296,26 @@ SalPrinter* GtkInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter ) * for each pair, so we can accurately restore * it later. */ -thread_local sal_uIntPtr GtkYieldMutex::yieldCount; +thread_local std::stack<sal_uIntPtr> GtkYieldMutex::yieldCounts; void GtkYieldMutex::ThreadsEnter() { acquire(); - for (; yieldCount != 0; --yieldCount) { - acquire(); + if (!yieldCounts.empty()) { + auto n = yieldCounts.top(); + yieldCounts.pop(); + for (; n != 0; --n) { + acquire(); + } } } void GtkYieldMutex::ThreadsLeave() { assert(mnCount != 0); - assert(yieldCount == 0); - yieldCount = mnCount - 1; - for (sal_uIntPtr i = 0; i != yieldCount + 1; ++i) { + auto n = mnCount - 1; + yieldCounts.push(n); + for (sal_uIntPtr i = 0; i != n + 1; ++i) { release(); } } |