Merge lp:~timo-jyrinki/libunity/blacklist-crash-1029949-6.0 into lp:libunity/6.0

Proposed by Timo Jyrinki
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 188
Merged at revision: 188
Proposed branch: lp:~timo-jyrinki/libunity/blacklist-crash-1029949-6.0
Merge into: lp:libunity/6.0
Diff against target: 303 lines (+134/-69)
5 files modified
src/unity-sound-menu-mpris.vala (+18/-19)
test/vala/Makefile.am (+60/-49)
test/vala/Makefile.integration_tests (+0/-1)
test/vala/blacklist-crash-1029949-test-case.vala (+44/-0)
test/vala/test-mpris-backend-server.vala (+12/-0)
To merge this branch: bzr merge lp:~timo-jyrinki/libunity/blacklist-crash-1029949-6.0
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
Review via email: mp+133197@code.launchpad.net

Commit message

Backport a fix to libunity 6.0: Fix crash when adding or removing players from the blacklist. (LP: #1029949)

Description of the change

Backport a fix to libunity 6.0: Fix crash when adding or removing players from the blacklist. (LP: #1029949)

To post a comment you must log in.
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Works for me. Approving!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-sound-menu-mpris.vala'
2--- src/unity-sound-menu-mpris.vala 2012-09-20 19:52:53 +0000
3+++ src/unity-sound-menu-mpris.vala 2012-11-07 08:48:20 +0000
4@@ -376,30 +376,29 @@
5 }
6
7 private void add_to_blacklist ()
8- {
9- var already_bl = this.settings.get_strv ("blacklisted-media-players");
10- var new_bl = new ArrayList<string>();
11-
12- foreach (var s in already_bl){
13- if ( s == get_blacklist_name()) return;
14- Trace.log_object (this, "add_to_blacklist: %s", s);
15- new_bl.add(s);
16+ {
17+ var blacklist = new GLib.VariantBuilder (new VariantType("as"));
18+ foreach (var already_blacklisted in this.settings.get_strv("blacklisted-media-players"))
19+ {
20+ if (already_blacklisted == get_blacklist_name ())
21+ return;
22+ blacklist.add("s", already_blacklisted);
23 }
24- new_bl.add (get_blacklist_name());
25- this.settings.set_strv ("blacklisted-media-players",
26- new_bl.to_array());
27+ blacklist.add("s", get_blacklist_name());
28+
29+ this.settings.set_value("blacklisted-media-players", blacklist.end());
30 }
31
32- private void remove_from_blacklist ()
33+ private void remove_from_blacklist()
34 {
35- var already_bl = this.settings.get_strv ("blacklisted-media-players");
36- var new_bl = new ArrayList<string>();
37- foreach (string s in already_bl){
38- if ( s == get_blacklist_name() )continue;
39- new_bl.add(s);
40+ var blacklist = new GLib.VariantBuilder(new VariantType("as"));
41+ foreach (var already_blacklisted in this.settings.get_strv("blacklisted-media-players"))
42+ {
43+ if (already_blacklisted == get_blacklist_name())
44+ continue;
45+ blacklist.add(already_blacklisted);
46 }
47- this.settings.set_strv( "blacklisted-media-players",
48- new_bl.to_array());
49+ this.settings.set_value("blacklisted-media-players", blacklist.end());
50 }
51 }
52 /****************************************************************************************/
53
54=== modified file 'test/vala/Makefile.am'
55--- test/vala/Makefile.am 2012-09-26 08:45:52 +0000
56+++ test/vala/Makefile.am 2012-11-07 08:48:20 +0000
57@@ -2,57 +2,57 @@
58
59 DISTCHECK_CONFIGURE_FLAGS = --enable-integration-tests=no
60
61-check_PROGRAMS = test-vala test-lens test-remote-scope
62+check_PROGRAMS = test-vala test-lens test-remote-scope test-blacklist-crash
63
64 AM_CPPFLAGS = \
65- -I$(top_srcdir) \
66- -I$(top_builddir)/protocol \
67- -I$(top_builddir)/src \
68- -DBUILDDIR=\"$(top_builddir)\" \
69- -DTESTDIR=\"$(top_srcdir)/test\" \
70- -DTESTVALADIR=\"$(top_srcdir)/test/vala\" \
71- -DG_SETTINGS_ENABLE_BACKEND \
72- $(LIBUNITY_CFLAGS) \
73- $(LIBUNITY_LIBS)
74+ -I$(top_srcdir) \
75+ -I$(top_builddir)/protocol \
76+ -I$(top_builddir)/src \
77+ -DBUILDDIR=\"$(top_builddir)\" \
78+ -DTESTDIR=\"$(top_srcdir)/test\" \
79+ -DTESTVALADIR=\"$(top_srcdir)/test/vala\" \
80+ -DG_SETTINGS_ENABLE_BACKEND \
81+ $(LIBUNITY_CFLAGS) \
82+ $(LIBUNITY_LIBS)
83
84-if !ENABLE_C_WARNINGS
85- AM_CPPFLAGS += -w
86+if ENABLE_C_WARNINGS
87+ AM_CPPFLAGS += -w
88 endif
89
90 if ENABLE_TRACE_LOG
91- AM_CPPFLAGS += -DENABLE_UNITY_TRACE_LOG
92+ AM_CPPFLAGS += -DENABLE_UNITY_TRACE_LOG
93 endif
94
95 AM_VALAFLAGS = \
96- --vapidir=$(top_builddir)/src \
97- --vapidir=$(top_builddir)/protocol \
98- --vapidir=$(top_srcdir)/test/vala \
99- --pkg unity-protocol \
100- --pkg unity-internal \
101- --pkg config \
102- $(LIBUNITY_PACKAGES) \
103- $(MAINTAINER_VALAFLAGS) \
104- $(NULL)
105+ --vapidir=$(top_builddir)/src \
106+ --vapidir=$(top_builddir)/protocol \
107+ --vapidir=$(top_srcdir)/test/vala \
108+ --pkg unity-protocol \
109+ --pkg unity-internal \
110+ --pkg config \
111+ $(LIBUNITY_PACKAGES) \
112+ $(MAINTAINER_VALAFLAGS) \
113+ $(NULL)
114
115 test_libs = \
116- $(top_builddir)/src/libunity.la \
117- $(top_builddir)/protocol/libunity-protocol-private.la \
118- $(LIBUNITY_LIBS)
119+ $(top_builddir)/src/libunity.la \
120+ $(top_builddir)/protocol/libunity-protocol-private.la \
121+ $(LIBUNITY_LIBS)
122
123-TEST_PROGS += test-vala test-lens
124+TEST_PROGS += test-vala test-lens test-blacklist-crash
125
126 test_vala_LDADD = $(test_libs)
127
128 test_vala_VALASOURCES = \
129- test-appinfo-manager.vala \
130- test-filters.vala \
131- test-io.vala \
132- test-launcher.vala \
133- test-preferences.vala \
134- test-previews.vala \
135- test-scope-signals.vala \
136- test-vala.vala \
137- $(NULL)
138+ test-appinfo-manager.vala \
139+ test-filters.vala \
140+ test-io.vala \
141+ test-launcher.vala \
142+ test-preferences.vala \
143+ test-previews.vala \
144+ test-scope-signals.vala \
145+ test-vala.vala \
146+ $(NULL)
147 nodist_test_vala_SOURCES = $(test_vala_VALASOURCES:.vala=.c)
148
149 test_lens_LDADD = $(test_libs)
150@@ -63,11 +63,16 @@
151 test_remote_scope_VALASOURCES = test-remote-scope.vala
152 nodist_test_remote_scope_SOURCES = $(test_remote_scope_VALASOURCES:.vala=.c)
153
154+test_blacklist_crash_LDADD = $(test_libs)
155+test_blacklist_crash_VALASOURCES = blacklist-crash-1029949-test-case.vala
156+nodist_test_blacklist_crash_SOURCES = $(test_blacklist_crash_VALASOURCES:.vala=.c)
157+
158 BUILT_SOURCES = \
159- test-vala.vala.stamp \
160- test-lens.vala.stamp \
161- test-remote-scope.vala.stamp \
162- $(NULL)
163+ test-vala.vala.stamp \
164+ test-lens.vala.stamp \
165+ test-remote-scope.vala.stamp \
166+ test-blacklist-crash.vala.stamp \
167+ $(NULL)
168
169 test-vala.vala.stamp: $(test_vala_VALASOURCES)
170 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
171@@ -81,21 +86,27 @@
172 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
173 @touch $@
174
175+test-blacklist-crash.vala.stamp: $(test_blacklist_crash_VALASOURCES)
176+ $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
177+ @touch $@
178+
179 include Makefile.integration_tests
180
181 EXTRA_DIST += \
182- $(test_vala_VALASOURCES) \
183- $(test_lens_VALASOURCES) \
184- $(test_remote_scope_VALASOURCES) \
185- config.vapi \
186- $(NULL)
187+ $(test_vala_VALASOURCES) \
188+ $(test_lens_VALASOURCES) \
189+ $(test_remote_scope_VALASOURCES) \
190+ $(test_blacklist_crash_VALASOURCES) \
191+ config.vapi \
192+ $(NULL)
193
194 CLEANFILES = \
195- *.stamp \
196- $(test_vala_VALASOURCES:.vala=.c) \
197- $(test_lens_VALASOURCES:.vala=.c) \
198- $(test_remote_scope_VALASOURCES:.vala=.c) \
199- $(NULL)
200+ *.stamp \
201+ $(test_vala_VALASOURCES:.vala=.c) \
202+ $(test_lens_VALASOURCES:.vala=.c) \
203+ $(test_remote_scope_VALASOURCES:.vala=.c) \
204+ $(test_blacklist_crash_VALASOURCES:.vala=.c) \
205+ $(NULL)
206
207 # START HEADLESS TESTS
208 if ENABLE_HEADLESS_TESTS
209
210=== modified file 'test/vala/Makefile.integration_tests'
211--- test/vala/Makefile.integration_tests 2012-08-07 12:31:44 +0000
212+++ test/vala/Makefile.integration_tests 2012-11-07 08:48:20 +0000
213@@ -139,4 +139,3 @@
214 test-mpris-backend-prop-updates-server.vala.stamp: $(test_mpris_backend_prop_updates_server_VALASOURCES)
215 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
216 @touch $@
217-
218
219=== added file 'test/vala/blacklist-crash-1029949-test-case.vala'
220--- test/vala/blacklist-crash-1029949-test-case.vala 1970-01-01 00:00:00 +0000
221+++ test/vala/blacklist-crash-1029949-test-case.vala 2012-11-07 08:48:20 +0000
222@@ -0,0 +1,44 @@
223+using Gee;
224+using Unity;
225+
226+
227+
228+int main(string[] args)
229+{
230+ int i = 0;
231+ var loop = new MainLoop();
232+ var time = new TimeoutSource(10);
233+ MusicPlayer test_player = null;
234+
235+ time.set_callback(() => {
236+ const string desktop_file_name = "rhythmbox.desktop";
237+ test_player = new MusicPlayer(desktop_file_name);
238+ test_player.export();
239+
240+ return false;
241+ });
242+ time.attach(loop.get_context());
243+
244+ var thread_timer = new TimeoutSource(100);
245+ thread_timer.set_callback(() => {
246+ set_blacklisted(test_player);
247+ if (++i < 100)
248+ return true;
249+ test_player.unexport();
250+ loop.quit();
251+ return false;
252+ });
253+ thread_timer.attach(loop.get_context());
254+
255+ loop.run();
256+
257+ return 0;
258+}
259+
260+void* set_blacklisted(MusicPlayer test_player)
261+{
262+ int raw_blacklist = Random.int_range(0, 2);
263+ bool blacklist = (bool) raw_blacklist;
264+ test_player.is_blacklisted = blacklist;
265+ return null;
266+}
267
268=== modified file 'test/vala/test-mpris-backend-server.vala'
269--- test/vala/test-mpris-backend-server.vala 2011-11-25 12:13:04 +0000
270+++ test/vala/test-mpris-backend-server.vala 2012-11-07 08:48:20 +0000
271@@ -16,6 +16,9 @@
272
273 public bool escape ()
274 {
275+ // this is some cleanup
276+ this.player.menu_player.is_blacklisted = false;
277+
278 this.mainloop.quit ();
279 return false;
280 }
281@@ -73,6 +76,8 @@
282 player.menu_player.player_menu = player_root;
283
284 player.menu_player.add_playlist (pl2);
285+
286+ Timeout.add (5, blacklist_self);
287
288 //The manual test of the playlistchanged signal, please leave commented
289 //Timeout.add (5, change_playlist_name);
290@@ -81,6 +86,13 @@
291 return false;
292 }
293
294+ // Regression test to ensure that setting blacklist does not cause a segfault
295+ public bool blacklist_self()
296+ {
297+ this.player.menu_player.is_blacklisted = true;
298+ return false;
299+ }
300+
301 // Manual test of the playlist name change signal
302 // Can't test this from the other side of dbus since there is no api to change
303 // or edit playlists yet ...

Subscribers

People subscribed via source and target branches

to all changes: