Merge lp:~linaro-graphics-wg/unity/ubus-gtypeinit into lp:unity

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Jay Taoko
Approved revision: no longer in the source branch.
Merged at revision: 2140
Proposed branch: lp:~linaro-graphics-wg/unity/ubus-gtypeinit
Merge into: lp:unity
Diff against target: 13 lines (+3/-0)
1 file modified
plugins/unityshell/src/ubus-server.cpp (+3/-0)
To merge this branch: bzr merge lp:~linaro-graphics-wg/unity/ubus-gtypeinit
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Jay Taoko (community) Approve
Review via email: mp+97849@code.launchpad.net

Commit message

ubus: Ensure the GType system has been initialized before using any GTypes.

The unity plugin doesn't explicitly call g_type_init(), although it uses a
GObject for UBusServer. This currently works because the ccp plugin, which
gets loaded before the unity plugin, calls g_type_init(), but this is fragile.
If ccp is not used, g_type_init() is not called by the time UBusServer gets
initialized, leading to a crash. This patch ensures that the GType system
has been initialized before using UBusServer (it is safe to call g_type_init()
multiple times).

Description of the change

ubus: Ensure the GType system has been initialized before using any GTypes.

The unity plugin doesn't explicitly call g_type_init(), although it uses a
GObject for UBusServer. This currently works because the ccp plugin, which
gets loaded before the unity plugin, calls g_type_init(), but this is fragile.
If ccp is not used, g_type_init() is not called by the time UBusServer gets
initialized, leading to a crash. This patch ensures that the GType system
has been initialized before using UBusServer (it is safe to call g_type_init()
multiple times).

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) :
review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

No commit message specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/ubus-server.cpp'
2--- plugins/unityshell/src/ubus-server.cpp 2011-07-21 14:59:25 +0000
3+++ plugins/unityshell/src/ubus-server.cpp 2012-03-16 11:38:26 +0000
4@@ -195,6 +195,9 @@
5 UBusServer* server;
6 static gsize singleton;
7
8+ // Ensure GType has been initialized
9+ g_type_init();
10+
11 if (g_once_init_enter(&singleton))
12 {
13 server = (UBusServer*)g_object_new(UBUS_TYPE_SERVER, NULL);