Gentoo Archives: gentoo-commits

From: "Andreas HAttel (dilfridge)" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-office/libreoffice/files: libreoffice-4.1.3.2-kde-recursiverepaint.patch
Date: Sat, 07 Dec 2013 20:29:57
Message-Id: 20131207202949.2679120005@flycatcher.gentoo.org
1 dilfridge 13/12/07 20:29:49
2
3 Added: libreoffice-4.1.3.2-kde-recursiverepaint.patch
4 Log:
5 Backport patch against KDE recursive repaint crash from Git master, bug 489656. No testing, no keywords so far.
6
7 (Portage version: 2.2.7/cvs/Linux x86_64, signed Manifest commit with key EBE6A336BE19039C!)
8
9 Revision Changes Path
10 1.1 app-office/libreoffice/files/libreoffice-4.1.3.2-kde-recursiverepaint.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-office/libreoffice/files/libreoffice-4.1.3.2-kde-recursiverepaint.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-office/libreoffice/files/libreoffice-4.1.3.2-kde-recursiverepaint.patch?rev=1.1&content-type=text/plain
14
15 Index: libreoffice-4.1.3.2-kde-recursiverepaint.patch
16 ===================================================================
17 Minor modification for libreoffice-4.1: in line 137, reset Q_EMIT to
18 emit... dilfridge@g.o
19
20 From 13a34f4c6307d1bd2443cbf3fbd83bfdd8cdbafb Mon Sep 17 00:00:00 2001
21 From: Jan-Marek Glogowski <glogow@×××××××.de>
22 Date: Fri, 15 Nov 2013 13:42:15 +0000
23 Subject: Rewrite Qt4 based nested yield mutex locking.
24
25 The Qt event loop may start a nested event loop, when checking for
26 clipboard and Drag'n'Drop events.
27
28 Previously this was handled by running this nested yield loop
29 inside the main glib loop using
30 qApp->clipboard()->property( "useEventLoopWhenWaiting" );
31
32 But this results in nested paint events which crash LO:
33 QWidget::repaint: Recursive repaint detected
34
35 To prevend yield mutex deadlocks, check for nested event loops
36 and always release the yield lock before starting the nested Yield
37 event loop.
38
39 This fixes fdo#69002.
40
41 Change-Id: I7e827abd3489783053ec7123372742a32555875d
42 Reviewed-on: https://gerrit.libreoffice.org/6685
43 Reviewed-by: Michael Meeks <michael.meeks@×××××××××.com>
44 Reviewed-by: Thorsten Behrens <thb@××××××××××××××××××.org>
45 Tested-by: Thorsten Behrens <thb@××××××××××××××××××.org>
46 ---
47 diff --git a/vcl/unx/kde4/KDE4FilePicker.cxx b/vcl/unx/kde4/KDE4FilePicker.cxx
48 index ee4a6e3..cb20be4 100644
49 --- a/vcl/unx/kde4/KDE4FilePicker.cxx
50 +++ b/vcl/unx/kde4/KDE4FilePicker.cxx
51 @@ -58,6 +58,8 @@
52
53 #undef Region
54
55 +#include "generic/geninst.h"
56 +
57 using namespace ::com::sun::star;
58 using namespace ::com::sun::star::ui::dialogs;
59 using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
60 @@ -253,28 +255,16 @@ sal_Int16 SAL_CALL KDE4FilePicker::execute()
61 _dialog->setFilter(_filter);
62 _dialog->filterWidget()->setEditable(false);
63
64 - // At this point, SolarMutex is held. Opening the KDE file dialog here
65 - // can lead to QClipboard asking for clipboard contents. If LO core
66 - // is the owner of the clipboard content, this will block for 5 seconds
67 - // and timeout, since the clipboard thread will not be able to acquire
68 - // SolarMutex and thus won't be able to respond. If the event loops
69 - // are properly integrated and QClipboard can use a nested event loop
70 - // (see the KDE VCL plug), then this won't happen, but otherwise
71 - // simply release the SolarMutex here. The KDE file dialog does not
72 - // call back to the core, so this should be safe (and if it does,
73 - // SolarMutex will need to be re-acquired).
74 - long mutexrelease = 0;
75 - if( !qApp->clipboard()->property( "useEventLoopWhenWaiting" ).toBool())
76 - mutexrelease = Application::ReleaseSolarMutex();
77 - //block and wait for user input
78 + // We're entering a nested loop.
79 + // Release the yield mutex to prevent deadlocks.
80 int result = _dialog->exec();
81 +
82 // HACK: KFileDialog uses KConfig("kdeglobals") for saving some settings
83 // (such as the auto-extension flag), but that doesn't update KGlobal::config()
84 // (which is probably a KDE bug), so force reading the new configuration,
85 // otherwise the next opening of the dialog would use the old settings.
86 KGlobal::config()->reparseConfiguration();
87 - if( !qApp->clipboard()->property( "useEventLoopWhenWaiting" ).toBool())
88 - Application::AcquireSolarMutex( mutexrelease );
89 +
90 if( result == KFileDialog::Accepted)
91 return ExecutableDialogResults::OK;
92
93 diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
94 index 8e0eb67..67d7a4d 100644
95 --- a/vcl/unx/kde4/KDEXLib.cxx
96 +++ b/vcl/unx/kde4/KDEXLib.cxx
97 @@ -225,9 +225,6 @@ void KDEXLib::setupEventLoop()
98 eventLoopType = GlibEventLoop;
99 old_gpoll = g_main_context_get_poll_func( NULL );
100 g_main_context_set_poll_func( NULL, gpoll_wrapper );
101 - // set QClipboard to use event loop, otherwise the main thread will hold
102 - // SolarMutex locked, which will prevent the clipboard thread from answering
103 - m_pApplication->clipboard()->setProperty( "useEventLoopWhenWaiting", true );
104 return;
105 }
106 #endif
107 @@ -244,9 +241,6 @@ void KDEXLib::setupEventLoop()
108 eventLoopType = QtUnixEventLoop;
109 QInternal::callFunction( QInternal::GetUnixSelectFunction, reinterpret_cast< void** >( &qt_select ));
110 QInternal::callFunction( QInternal::SetUnixSelectFunction, reinterpret_cast< void** >( lo_select ));
111 - // set QClipboard to use event loop, otherwise the main thread will hold
112 - // SolarMutex locked, which will prevent the clipboard thread from answering
113 - m_pApplication->clipboard()->setProperty( "useEventLoopWhenWaiting", true );
114 return;
115 }
116 #endif
117 @@ -300,6 +294,9 @@ void KDEXLib::socketNotifierActivated( int fd )
118
119 void KDEXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
120 {
121 + // Nested yield loop counter.
122 + static int loop_depth = 0;
123 +
124 if( eventLoopType == LibreOfficeEventLoop )
125 {
126 if( qApp->thread() == QThread::currentThread())
127 @@ -310,13 +307,24 @@ void KDEXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
128 }
129 return SalXLib::Yield( bWait, bHandleAllCurrentEvents );
130 }
131 +
132 // if we are the main thread (which is where the event processing is done),
133 // good, just do it
134 - if( qApp->thread() == QThread::currentThread())
135 + if( qApp->thread() == QThread::currentThread()) {
136 + // Release the yield lock before entering a nested loop.
137 + if (loop_depth > 0)
138 + SalYieldMutexReleaser aReleaser;
139 + loop_depth++;
140 processYield( bWait, bHandleAllCurrentEvents );
141 - else
142 - { // if this deadlocks, event processing needs to go into a separate thread
143 - // or some other solution needs to be found
144 + loop_depth--;
145 + }
146 + else {
147 + // we were called from another thread;
148 + // release the yield lock to prevent deadlock.
149 + SalYieldMutexReleaser aReleaser;
150 +
151 + // if this deadlocks, event processing needs to go into a separate
152 + // thread or some other solution needs to be found
153 emit processYieldSignal( bWait, bHandleAllCurrentEvents );
154 }
155 }
156 --
157 cgit v0.9.0.2-2-gbebe