Merge lp:~vanvugt/compiz-core/fix-921406 into lp:compiz-core/0.9.5

Proposed by Daniel van Vugt
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 2962
Merged at revision: 2963
Proposed branch: lp:~vanvugt/compiz-core/fix-921406
Merge into: lp:compiz-core/0.9.5
Diff against target: 133 lines (+51/-0)
2 files modified
plugins/composite/tests/paintscheduler/test-paintscheduler.cpp (+46/-0)
src/signalsource.cpp (+5/-0)
To merge this branch: bzr merge lp:~vanvugt/compiz-core/fix-921406
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Review via email: mp+90053@code.launchpad.net

Description of the change

Fix build failures with glib 2.30 (oneiric) (LP: #921406)

Amazingly, there is no compatible GThread/GMutex/GCond API that is compatible with both glib 2.30 (oneiric) and 2.31 (precise). So we need to #if them :(

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Messy, but if it needs to be...

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

Ack, we also hit similar problems in unity too

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Actually you could emulate the old 2.30 API using the new one (2.31) with a bunch of wrapper functions and/or macros. But since this is the only place in compiz affected, not worth doing (yet).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/composite/tests/paintscheduler/test-paintscheduler.cpp'
2--- plugins/composite/tests/paintscheduler/test-paintscheduler.cpp 2012-01-24 09:30:19 +0000
3+++ plugins/composite/tests/paintscheduler/test-paintscheduler.cpp 2012-01-25 07:39:23 +0000
4@@ -166,8 +166,13 @@
5 int drmFD;
6 DRMInfo *info;
7 GThread *eventThread;
8+#if GLIB_CHECK_VERSION(2, 31, 0)
9 GMutex eventMutex;
10 GCond eventCondition;
11+#else
12+ GMutex *eventMutex;
13+ GCond *eventCondition;
14+#endif
15 bool pendingVBlank;
16 };
17
18@@ -456,13 +461,22 @@
19
20 drmWaitVBlank (fd, &vbl);
21
22+#if GLIB_CHECK_VERSION(2, 31, 0)
23 g_mutex_lock (&info->self->eventMutex);
24+#else
25+ g_mutex_lock (info->self->eventMutex);
26+#endif
27
28 if (info->self->timingCount != info->self->periods.size ())
29 info->self->pendingVBlank = true;
30
31+#if GLIB_CHECK_VERSION(2, 31, 0)
32 g_cond_signal (&info->self->eventCondition);
33 g_mutex_unlock (&info->self->eventMutex);
34+#else
35+ g_cond_signal (info->self->eventCondition);
36+ g_mutex_unlock (info->self->eventMutex);
37+#endif
38 }
39
40 gpointer
41@@ -506,8 +520,13 @@
42 {
43 const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx" };
44
45+#if GLIB_CHECK_VERSION(2, 31, 0)
46 g_mutex_init (&eventMutex);
47 g_cond_init (&eventCondition);
48+#else
49+ eventMutex = g_mutex_new ();
50+ eventCondition = g_cond_new ();
51+#endif
52
53 for (unsigned int i = 0; i < ARRAY_SIZE (modules); i++)
54 {
55@@ -555,7 +574,12 @@
56 evctx.vblank_handler = DRMVBlankWaiter::vblankHandler;
57 evctx.page_flip_handler = NULL;
58
59+#if GLIB_CHECK_VERSION(2, 31, 0)
60 eventThread = g_thread_try_new ("drm_wait_t", &DRMVBlankWaiter::drmEventHandlerThread, (void *) this, NULL);
61+#else
62+ eventThread = g_thread_create (&DRMVBlankWaiter::drmEventHandlerThread,
63+ (void *) this, TRUE, NULL);
64+#endif
65
66 if (!eventThread)
67 {
68@@ -571,6 +595,15 @@
69 delete info;
70
71 drmClose (drmFD);
72+
73+#if GLIB_CHECK_VERSION(2, 31, 0)
74+ g_mutex_clear (&eventMutex);
75+ g_cond_clear (&eventCondition);
76+#else
77+ g_mutex_free (eventMutex);
78+ g_cond_free (eventCondition);
79+#endif
80+
81 }
82
83 NilVBlankWaiter::NilVBlankWaiter (DummyPaintDispatch *o, unsigned int n) :
84@@ -606,12 +639,21 @@
85 {
86 VBlankWaiter::time_value tv;
87
88+#if GLIB_CHECK_VERSION(2, 31, 0)
89 g_mutex_lock (&eventMutex);
90 if (!pendingVBlank && !owner->isDone ())
91 g_cond_wait (&eventCondition, &eventMutex);
92
93 pendingVBlank = false;
94 g_mutex_unlock (&eventMutex);
95+#else
96+ g_mutex_lock (eventMutex);
97+ if (!pendingVBlank && !owner->isDone ())
98+ g_cond_wait (eventCondition, eventMutex);
99+
100+ pendingVBlank = false;
101+ g_mutex_unlock (eventMutex);
102+#endif
103
104 gettimeofday (&tv, NULL);
105
106@@ -679,6 +721,10 @@
107
108 int main (void)
109 {
110+#if !GLIB_CHECK_VERSION(2, 31, 0)
111+ g_thread_init (NULL);
112+#endif
113+
114 gettimeofday (&SleepVBlankWaiter::start_time, NULL);
115
116 TimeoutHandler *th = new TimeoutHandler ();
117
118=== modified file 'src/signalsource.cpp'
119--- src/signalsource.cpp 2012-01-21 13:34:31 +0000
120+++ src/signalsource.cpp 2012-01-25 07:39:23 +0000
121@@ -24,7 +24,12 @@
122 */
123
124 #include "privatesignalsource.h"
125+
126+/* Add missing decls: https://bugzilla.gnome.org/show_bug.cgi?id=663880 */
127+#include <glib.h>
128+G_BEGIN_DECLS
129 #include <glib-unix.h>
130+G_END_DECLS
131
132 CompSignalSource *
133 CompSignalSource::create (int signum, const callbackFunc &f)

Subscribers

People subscribed via source and target branches