summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-16 13:05:40 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-16 12:14:30 +0000
commit81ed73d0867e0322b450314c474fd01404671f0e (patch)
treeae675940703050612f835cd8e9d13dbee876c3fb /vcl
parent0cfaabfc9457d15c819811a10deaf00eaef0e260 (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 (cherry picked from commit ef1dc167cd3339b1e92d8e18b1f5c3c2cfbec6ab) Reviewed-on: https://gerrit.libreoffice.org/26365 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/gtk/gtkinst.hxx6
-rw-r--r--vcl/unx/gtk/gtkinst.cxx16
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();
}
}