[Libreoffice-commits] core.git: vcl/inc vcl/unx
Stephan Bergmann
sbergman at redhat.com
Thu Jun 16 11:09:50 UTC 2016
vcl/inc/unx/gtk/gtkinst.hxx | 6 +++++-
vcl/unx/gtk/gtkinst.cxx | 16 ++++++++++------
2 files changed, 15 insertions(+), 7 deletions(-)
New commits:
commit ef1dc167cd3339b1e92d8e18b1f5c3c2cfbec6ab
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 16 13:05:40 2016 +0200
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
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 86002fa..6212d5d 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 04d7822..22cdca8 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();
}
}
More information about the Libreoffice-commits
mailing list