diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-06-16 13:05:40 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-06-16 13:05:40 +0200 |
commit | ef1dc167cd3339b1e92d8e18b1f5c3c2cfbec6ab (patch) | |
tree | f1f0ceb314e46d24ce0529463dd385c427b5a5d4 /vcl | |
parent | cfc22e4614499de3987fcf4ca178e6349666c9af (diff) |
tdf#100412: Cope with recursive gdk_threads_enter/_leave
07157e644fa9666850767ff6bd54c1511167a0a2 "Keep track of ThreadsEnter/Leave
acquire counts per thread" was done under the assumption that these calls never
happen recursively, but tdf#100412 makes it look like such calls do happen, so
that in a pattern
gdk_threads_enter
gdk_threads_enter
gdk_threads_leave
gdk_threads_leave
the second gdk_threads_leave could find yieldCount non-zero.
Change-Id: If9837764d22473f21cf5b10d769929f3c86a0ba7
Diffstat (limited to 'vcl')
-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 04d78222f90b..22cdca8f1938 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(); } } |