Merge lp:~azzar1/compiz/fix-1214459 into lp:compiz/0.9.11

Proposed by Andrea Azzarone
Status: Merged
Approved by: Stephen M. Webb
Approved revision: 3784
Merged at revision: 3783
Proposed branch: lp:~azzar1/compiz/fix-1214459
Merge into: lp:compiz/0.9.11
Diff against target: 238 lines (+25/-39)
9 files modified
src/eventsource.cpp (+2/-3)
src/privateeventsource.h (+1/-3)
src/privateiosource.h (+1/-3)
src/privatescreen.h (+6/-9)
src/screen.cpp (+8/-10)
src/timer/src/privatetimeoutsource.h (+1/-1)
src/timer/src/timer.cpp (+2/-6)
src/timer/tests/test-timer.h (+1/-1)
tests/integration/glib/glib_integration_test.cpp (+3/-3)
To merge this branch: bzr merge lp:~azzar1/compiz/fix-1214459
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Stephen M. Webb Approve
Review via email: mp+181090@code.launchpad.net

Commit message

Use Glib::RefPtr<Glib::Source> in glib_integration_test. After the fix of bug https://bugzilla.gnome.org/show_bug.cgi?id=561885 Glib::Source::~Source is called when both Source::unreference() and SourceCallbackData::destroy_notify_callback() are called.

Description of the change

== Problem ==
Bug #1214459: Failing GLibSourceDestroyIntegration unit tests on compiz/0.9.10

== Fix ==
After the fix of bug https://bugzilla.gnome.org/show_bug.cgi?id=561885 Glib::Source::~Source is called when both Source::unreference() and SourceCallbackData::destroy_notify_callback() are called. It forces us to use Glib::Source in couple with Glib::RefPtr.

== Test ==
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Stephen M. Webb (bregma) wrote :

Better to leak than to crash.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/eventsource.cpp'
--- src/eventsource.cpp 2012-12-02 17:41:42 +0000
+++ src/eventsource.cpp 2013-08-20 17:45:34 +0000
@@ -27,11 +27,10 @@
27#include "privateeventsource.h"27#include "privateeventsource.h"
28#include "core/screen.h"28#include "core/screen.h"
2929
30CompEventSource *30Glib::RefPtr<CompEventSource>
31CompEventSource::create ()31CompEventSource::create ()
32{32{
33 return new CompEventSource (screen->dpy (),33 return Glib::RefPtr<CompEventSource> (new CompEventSource (screen->dpy (), ConnectionNumber (screen->dpy ())));
34 ConnectionNumber (screen->dpy ()));
35}34}
3635
37sigc::connection36sigc::connection
3837
=== modified file 'src/privateeventsource.h'
--- src/privateeventsource.h 2012-12-02 12:06:02 +0000
+++ src/privateeventsource.h 2013-08-20 17:45:34 +0000
@@ -37,9 +37,7 @@
3737
38 virtual ~CompEventSource ();38 virtual ~CompEventSource ();
3939
40 static40 static Glib::RefPtr<CompEventSource> create ();
41 CompEventSource *
42 create ();
4341
44 sigc::connection connect (const sigc::slot <bool> &slot);42 sigc::connection connect (const sigc::slot <bool> &slot);
4543
4644
=== modified file 'src/privateiosource.h'
--- src/privateiosource.h 2012-12-02 12:06:02 +0000
+++ src/privateiosource.h 2013-08-20 17:45:34 +0000
@@ -47,9 +47,7 @@
47 virtual ~CompWatchFd ();47 virtual ~CompWatchFd ();
4848
49 static49 static
50 CompWatchFd * create (int,50 Glib::RefPtr<CompWatchFd> create (int, Glib::IOCondition, FdWatchCallBack);
51 Glib::IOCondition,
52 FdWatchCallBack);
5351
54 protected:52 protected:
5553
5654
=== modified file 'src/privatescreen.h'
--- src/privatescreen.h 2013-05-12 08:20:10 +0000
+++ src/privatescreen.h 2013-08-20 17:45:34 +0000
@@ -314,14 +314,11 @@
314314
315 Glib::RefPtr <Glib::MainLoop> mainloop;315 Glib::RefPtr <Glib::MainLoop> mainloop;
316316
317 /* We cannot use RefPtrs. See317 Glib::RefPtr <CompEventSource> source;
318 * https://bugzilla.gnome.org/show_bug.cgi?id=561885318 Glib::RefPtr <CompTimeoutSource> timeout;
319 */319 CompSignalSource *sighupSource;
320 CompEventSource * source;320 CompSignalSource *sigtermSource;
321 CompTimeoutSource * timeout;321 CompSignalSource *sigintSource;
322 CompSignalSource * sighupSource;
323 CompSignalSource * sigtermSource;
324 CompSignalSource * sigintSource;
325 Glib::RefPtr <Glib::MainContext> ctx;322 Glib::RefPtr <Glib::MainContext> ctx;
326323
327 CompFileWatchList fileWatch;324 CompFileWatchList fileWatch;
@@ -329,7 +326,7 @@
329326
330 // TODO - almost certainly the wrong data structure327 // TODO - almost certainly the wrong data structure
331 // Why not a std::map<CompWatchFdHandle, CompWatchFd>?328 // Why not a std::map<CompWatchFdHandle, CompWatchFd>?
332 std::list< CompWatchFd * > watchFds;329 std::list<Glib::RefPtr<CompWatchFd> > watchFds;
333 CompWatchFdHandle lastWatchFdHandle;330 CompWatchFdHandle lastWatchFdHandle;
334331
335 bool grabbed; /* true once we receive a GrabNotify332 bool grabbed; /* true once we receive a GrabNotify
336333
=== modified file 'src/screen.cpp'
--- src/screen.cpp 2013-05-13 13:27:30 +0000
+++ src/screen.cpp 2013-08-20 17:45:34 +0000
@@ -272,12 +272,12 @@
272{272{
273}273}
274274
275CompWatchFd *275Glib::RefPtr<CompWatchFd>
276CompWatchFd::create (int fd,276CompWatchFd::create (int fd,
277 Glib::IOCondition events,277 Glib::IOCondition events,
278 FdWatchCallBack callback)278 FdWatchCallBack callback)
279{279{
280 return new CompWatchFd (fd, events, callback);280 return Glib::RefPtr<CompWatchFd> (new CompWatchFd (fd, events, callback));
281}281}
282282
283CompWatchFdHandle283CompWatchFdHandle
@@ -308,7 +308,7 @@
308 if (events & POLLHUP)308 if (events & POLLHUP)
309 gEvents |= Glib::IO_HUP;309 gEvents |= Glib::IO_HUP;
310310
311 CompWatchFd *watchFd = CompWatchFd::create (fd, gEvents, callBack);311 Glib::RefPtr<CompWatchFd> watchFd = CompWatchFd::create (fd, gEvents, callBack);
312312
313 watchFd->attach (ctx);313 watchFd->attach (ctx);
314314
@@ -333,8 +333,8 @@
333void333void
334cps::EventManager::removeWatchFd (CompWatchFdHandle handle)334cps::EventManager::removeWatchFd (CompWatchFdHandle handle)
335{335{
336 std::list<CompWatchFd * >::iterator it;336 std::list<Glib::RefPtr<CompWatchFd> >::iterator it;
337 CompWatchFd * w;337 Glib::RefPtr<CompWatchFd> w;
338338
339 for (it = watchFds.begin();339 for (it = watchFds.begin();
340 it != watchFds.end (); ++it)340 it != watchFds.end (); ++it)
@@ -354,7 +354,6 @@
354 return;354 return;
355 }355 }
356356
357 delete w;
358 watchFds.erase (it);357 watchFds.erase (it);
359}358}
360359
@@ -5271,10 +5270,10 @@
5271 /* Not guaranteed to be created by EventManager's constructor */5270 /* Not guaranteed to be created by EventManager's constructor */
5272 if (timeout)5271 if (timeout)
5273 {5272 {
5274 /* This will implicitly call ~CompTimeoutSource5273
5275 * See LP: #1085590 */
5276 g_source_destroy (timeout->gobj ());5274 g_source_destroy (timeout->gobj ());
5277 }5275 }
5276
5278 delete sigintSource;5277 delete sigintSource;
5279 delete sigtermSource;5278 delete sigtermSource;
5280 delete sighupSource;5279 delete sighupSource;
@@ -5282,12 +5281,11 @@
5282 /* Not guaranteed to be created by EventManager's constructor */5281 /* Not guaranteed to be created by EventManager's constructor */
5283 if (source)5282 if (source)
5284 {5283 {
5285 /* This will implicitly call ~CompEventSource */
5286 g_source_destroy (source->gobj ());5284 g_source_destroy (source->gobj ());
5287 }5285 }
52885286
5289 /* This will implicitly call ~CompWatchFd */5287 /* This will implicitly call ~CompWatchFd */
5290 foreach (CompWatchFd *fd, watchFds)5288 foreach (Glib::RefPtr<CompWatchFd> fd, watchFds)
5291 g_source_destroy (fd->gobj ());5289 g_source_destroy (fd->gobj ());
52925290
5293 watchFds.clear ();5291 watchFds.clear ();
52945292
=== modified file 'src/timer/src/privatetimeoutsource.h'
--- src/timer/src/privatetimeoutsource.h 2012-12-02 12:06:02 +0000
+++ src/timer/src/privatetimeoutsource.h 2013-08-20 17:45:34 +0000
@@ -37,7 +37,7 @@
3737
38 virtual ~CompTimeoutSource ();38 virtual ~CompTimeoutSource ();
3939
40 static CompTimeoutSource * create (Glib::RefPtr <Glib::MainContext> &ctx);40 static Glib::RefPtr<CompTimeoutSource> create (Glib::RefPtr <Glib::MainContext> &ctx);
41 sigc::connection connect (const sigc::slot <bool> &slot);41 sigc::connection connect (const sigc::slot <bool> &slot);
4242
43 protected:43 protected:
4444
=== modified file 'src/timer/src/timer.cpp'
--- src/timer/src/timer.cpp 2012-09-05 13:04:40 +0000
+++ src/timer/src/timer.cpp 2013-08-20 17:45:34 +0000
@@ -56,10 +56,6 @@
56 set_priority (G_PRIORITY_DEFAULT);56 set_priority (G_PRIORITY_DEFAULT);
57 attach (ctx);57 attach (ctx);
5858
59 /* We have to unreference the source so that it is destroyed
60 * when the main context destroys it */
61 unreference ();
62
63 connect (sigc::mem_fun <bool, CompTimeoutSource> (this, &CompTimeoutSource::callback));59 connect (sigc::mem_fun <bool, CompTimeoutSource> (this, &CompTimeoutSource::callback));
64}60}
6561
@@ -73,10 +69,10 @@
73 return connect_generic (slot);69 return connect_generic (slot);
74}70}
7571
76CompTimeoutSource *72Glib::RefPtr<CompTimeoutSource>
77CompTimeoutSource::create (Glib::RefPtr <Glib::MainContext> &ctx)73CompTimeoutSource::create (Glib::RefPtr <Glib::MainContext> &ctx)
78{74{
79 return new CompTimeoutSource (ctx);75 return Glib::RefPtr<CompTimeoutSource> (new CompTimeoutSource (ctx));
80}76}
8177
82static const unsigned short COMPIZ_TIMEOUT_WAIT = 15;78static const unsigned short COMPIZ_TIMEOUT_WAIT = 15;
8379
=== modified file 'src/timer/tests/test-timer.h'
--- src/timer/tests/test-timer.h 2012-07-27 07:18:40 +0000
+++ src/timer/tests/test-timer.h 2013-08-20 17:45:34 +0000
@@ -48,7 +48,7 @@
4848
49 Glib::RefPtr <Glib::MainContext> mc;49 Glib::RefPtr <Glib::MainContext> mc;
50 Glib::RefPtr <Glib::MainLoop> ml;50 Glib::RefPtr <Glib::MainLoop> ml;
51 CompTimeoutSource *ts;51 Glib::RefPtr <CompTimeoutSource> ts;
52 std::deque <CompTimer *> timers;52 std::deque <CompTimer *> timers;
5353
54 int lastTimerTriggered;54 int lastTimerTriggered;
5555
=== modified file 'tests/integration/glib/glib_integration_test.cpp'
--- tests/integration/glib/glib_integration_test.cpp 2012-12-02 17:43:53 +0000
+++ tests/integration/glib/glib_integration_test.cpp 2013-08-20 17:45:34 +0000
@@ -119,7 +119,7 @@
119119
120TEST_F (GLibSourceDestroyIntegration, TimeoutSourceGSourceDestroy)120TEST_F (GLibSourceDestroyIntegration, TimeoutSourceGSourceDestroy)
121{121{
122 StubTimeoutSource *sts = new StubTimeoutSource (&die, context);122 Glib::RefPtr<StubTimeoutSource> sts(new StubTimeoutSource (&die, context));
123123
124 EXPECT_CALL (die, Die ());124 EXPECT_CALL (die, Die ());
125125
@@ -128,7 +128,7 @@
128128
129TEST_F (GLibSourceDestroyIntegration, EventSourceGSourceDestroy)129TEST_F (GLibSourceDestroyIntegration, EventSourceGSourceDestroy)
130{130{
131 StubEventSource *sts = new StubEventSource (&die);131 Glib::RefPtr<StubEventSource> sts(new StubEventSource (&die));
132132
133 sts->attach (context);133 sts->attach (context);
134134
@@ -142,7 +142,7 @@
142 Glib::IOCondition iocond = Glib::IO_IN;142 Glib::IOCondition iocond = Glib::IO_IN;
143 int fd = 0;143 int fd = 0;
144 FdWatchCallBack cb;144 FdWatchCallBack cb;
145 StubWatchFd *sts = new StubWatchFd (&die, fd, iocond, cb);145 Glib::RefPtr<StubWatchFd> sts(new StubWatchFd (&die, fd, iocond, cb));
146146
147 sts->attach (context);147 sts->attach (context);
148148

Subscribers

People subscribed via source and target branches