Merge lp:~unity-team/unity/unity.fix_801428 into lp:unity

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 1258
Proposed branch: lp:~unity-team/unity/unity.fix_801428
Merge into: lp:unity
Diff against target: 197 lines (+104/-15)
9 files modified
plugins/gtkloader/CMakeLists.txt (+5/-0)
plugins/gtkloader/gtkloader.xml.in (+7/-0)
plugins/gtkloader/src/gtkloader.cpp (+46/-0)
plugins/gtkloader/src/gtkloader.h (+42/-0)
plugins/unitydialog/CMakeLists.txt (+1/-1)
plugins/unitydialog/src/unitydialog.cpp (+1/-12)
plugins/unitydialog/unitydialog.xml.in (+1/-0)
plugins/unityshell/src/unityshell.cpp (+0/-2)
plugins/unityshell/unityshell.xml.in (+1/-0)
To merge this branch: bzr merge lp:~unity-team/unity/unity.fix_801428
Reviewer Review Type Date Requested Status
Marco Biscaro (community) Approve
Unity Team Pending
Review via email: mp+65761@code.launchpad.net

Description of the change

Fixes LP#801428 , work around a hang in gtk when doing gtk_init_check from multiple dlopen contexts

To post a comment you must log in.
Revision history for this message
Marco Biscaro (marcobiscaro2112) wrote :

Some minor details:

+ XSetErrorHandler (old_handler);

You're calling this method twice. I think it should be called just once, after loading gtk, right?

+ compLogMessage ("unitydialog", CompLogLevelError, "Couldn't initialize gtk");

The compiz plugin here is gtkloader, not unitydialog.

+bool
+GTKLoaderPluginVTable::init ()

The method should return a bool, even when the plugin is loaded successfully. This means that you should add a 'return true' as the last line of method (GCC 4.6 generates a warning about this).

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Thanks Marco!

Revision history for this message
Marco Biscaro (marcobiscaro2112) wrote :

Looks good! +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'plugins/gtkloader'
2=== added file 'plugins/gtkloader/CMakeLists.txt'
3--- plugins/gtkloader/CMakeLists.txt 1970-01-01 00:00:00 +0000
4+++ plugins/gtkloader/CMakeLists.txt 2011-06-27 10:52:55 +0000
5@@ -0,0 +1,5 @@
6+find_package (Compiz REQUIRED)
7+
8+include (CompizPlugin)
9+
10+compiz_plugin (gtkloader PKGDEPS gtk+-3.0)
11
12=== added file 'plugins/gtkloader/gtkloader.xml.in'
13--- plugins/gtkloader/gtkloader.xml.in 1970-01-01 00:00:00 +0000
14+++ plugins/gtkloader/gtkloader.xml.in 2011-06-27 10:52:55 +0000
15@@ -0,0 +1,7 @@
16+<compiz>
17+ <plugin name="gtkloader" useBcop="true">
18+ <_short>GTK Loader</_short>
19+ <_long>Initializes GTK once</_long>
20+ <category>Utility</category>
21+ </plugin>
22+</compiz>
23
24=== added directory 'plugins/gtkloader/src'
25=== added file 'plugins/gtkloader/src/gtkloader.cpp'
26--- plugins/gtkloader/src/gtkloader.cpp 1970-01-01 00:00:00 +0000
27+++ plugins/gtkloader/src/gtkloader.cpp 2011-06-27 10:52:55 +0000
28@@ -0,0 +1,46 @@
29+/*
30+ * Copyright (C) 2010 Canonical Ltd
31+ *
32+ * This program is free software: you can redistribute it and/or modify
33+ * it under the terms of the GNU General Public License version 3 as
34+ * published by the Free Software Foundation.
35+ *
36+ * This program is distributed in the hope that it will be useful,
37+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
38+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39+ * GNU General Public License for more details.
40+ *
41+ * You should have received a copy of the GNU General Public License
42+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
43+ *
44+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
45+ */
46+
47+#include "gtkloader.h"
48+
49+COMPIZ_PLUGIN_20090315 (gtkloader, GTKLoaderPluginVTable);
50+
51+GTKLoaderScreen::GTKLoaderScreen (CompScreen *screen) :
52+ PluginClassHandler <GTKLoaderScreen, CompScreen> (screen)
53+{
54+}
55+
56+bool
57+GTKLoaderPluginVTable::init ()
58+{
59+ int (*old_handler) (Display *, XErrorEvent *);
60+ old_handler = XSetErrorHandler (NULL);
61+
62+ XSetErrorHandler (old_handler);
63+
64+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
65+ return false;
66+
67+ if (!gtk_init_check (&programArgc, &programArgv))
68+ {
69+ compLogMessage ("gtkloader", CompLogLevelError, "Couldn't initialize gtk");
70+ return false;
71+ }
72+
73+ return true;
74+}
75
76=== added file 'plugins/gtkloader/src/gtkloader.h'
77--- plugins/gtkloader/src/gtkloader.h 1970-01-01 00:00:00 +0000
78+++ plugins/gtkloader/src/gtkloader.h 2011-06-27 10:52:55 +0000
79@@ -0,0 +1,42 @@
80+/*
81+ * Copyright (C) 2010 Canonical Ltd
82+ *
83+ * This program is free software: you can redistribute it and/or modify
84+ * it under the terms of the GNU General Public License version 3 as
85+ * published by the Free Software Foundation.
86+ *
87+ * This program is distributed in the hope that it will be useful,
88+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
89+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90+ * GNU General Public License for more details.
91+ *
92+ * You should have received a copy of the GNU General Public License
93+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
94+ *
95+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
96+ */
97+
98+#include <gtk/gtk.h>
99+#include <core/core.h>
100+#include <X11/Xatom.h>
101+#include <X11/Xproto.h>
102+#include <core/pluginclasshandler.h>
103+
104+#include "gtkloader_options.h"
105+
106+class GTKLoaderScreen :
107+ public PluginClassHandler <GTKLoaderScreen, CompScreen>,
108+ public GtkloaderOptions
109+{
110+ public:
111+
112+ GTKLoaderScreen (CompScreen *);
113+};
114+
115+class GTKLoaderPluginVTable :
116+ public CompPlugin::VTableForScreen <GTKLoaderScreen>
117+{
118+ public:
119+
120+ bool init ();
121+};
122
123=== modified file 'plugins/unitydialog/CMakeLists.txt'
124--- plugins/unitydialog/CMakeLists.txt 2011-05-20 17:08:22 +0000
125+++ plugins/unitydialog/CMakeLists.txt 2011-06-27 10:52:55 +0000
126@@ -2,5 +2,5 @@
127
128 include (CompizPlugin)
129
130-compiz_plugin (unitydialog PLUGINDEPS composite opengl PKGDEPS cairo cairo-xlib-xrender gtk+-2.0)
131+compiz_plugin (unitydialog PLUGINDEPS composite opengl PKGDEPS cairo cairo-xlib-xrender gtk+-3.0)
132
133
134=== modified file 'plugins/unitydialog/src/unitydialog.cpp'
135--- plugins/unitydialog/src/unitydialog.cpp 2011-06-09 12:29:00 +0000
136+++ plugins/unitydialog/src/unitydialog.cpp 2011-06-27 10:52:55 +0000
137@@ -1141,22 +1141,11 @@
138
139 bool
140 UnityDialogPluginVTable::init ()
141-{
142- int (*old_handler) (Display *, XErrorEvent *);
143- old_handler = XSetErrorHandler (NULL);
144-
145+{
146 if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
147 !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
148 !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
149 return false;
150
151- if (!gtk_init_check (&programArgc, &programArgv))
152- {
153- compLogMessage ("unitydialog", CompLogLevelError, "Couldn't initialize gtk");
154- return false;
155- }
156-
157- XSetErrorHandler (old_handler);
158-
159 return true;
160 }
161
162=== modified file 'plugins/unitydialog/unitydialog.xml.in'
163--- plugins/unitydialog/unitydialog.xml.in 2011-06-09 12:37:04 +0000
164+++ plugins/unitydialog/unitydialog.xml.in 2011-06-27 10:52:55 +0000
165@@ -7,6 +7,7 @@
166 <requirement>
167 <plugin>composite</plugin>
168 <plugin>opengl</plugin>
169+ <plugin>gtkloader</plugin>
170 </requirement>
171 <relation type="after">
172 <plugin>decor</plugin>
173
174=== modified file 'plugins/unityshell/src/unityshell.cpp'
175--- plugins/unityshell/src/unityshell.cpp 2011-06-12 23:21:36 +0000
176+++ plugins/unityshell/src/unityshell.cpp 2011-06-27 10:52:55 +0000
177@@ -846,8 +846,6 @@
178
179 unity_a11y_preset_environment ();
180
181- gtk_init (NULL, NULL);
182-
183 XSetErrorHandler (old_handler);
184
185 /* Wrap compiz interfaces */
186
187=== modified file 'plugins/unityshell/unityshell.xml.in'
188--- plugins/unityshell/unityshell.xml.in 2011-06-20 20:46:03 +0000
189+++ plugins/unityshell/unityshell.xml.in 2011-06-27 10:52:55 +0000
190@@ -34,6 +34,7 @@
191 <requirement>
192 <plugin>opengl</plugin>
193 <feature>largedesktop</feature>
194+ <plugin>gtkloader</plugin>
195 </requirement>
196 </deps>
197 <options>