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
=== modified file 'src/unity-sound-menu-mpris.vala'
--- src/unity-sound-menu-mpris.vala 2012-09-20 19:52:53 +0000
+++ src/unity-sound-menu-mpris.vala 2012-11-07 08:48:20 +0000
@@ -376,30 +376,29 @@
376 }376 }
377 377
378 private void add_to_blacklist ()378 private void add_to_blacklist ()
379 { 379 {
380 var already_bl = this.settings.get_strv ("blacklisted-media-players");380 var blacklist = new GLib.VariantBuilder (new VariantType("as"));
381 var new_bl = new ArrayList<string>();381 foreach (var already_blacklisted in this.settings.get_strv("blacklisted-media-players"))
382382 {
383 foreach (var s in already_bl){383 if (already_blacklisted == get_blacklist_name ())
384 if ( s == get_blacklist_name()) return;384 return;
385 Trace.log_object (this, "add_to_blacklist: %s", s); 385 blacklist.add("s", already_blacklisted);
386 new_bl.add(s);
387 }386 }
388 new_bl.add (get_blacklist_name());387 blacklist.add("s", get_blacklist_name());
389 this.settings.set_strv ("blacklisted-media-players",388
390 new_bl.to_array());389 this.settings.set_value("blacklisted-media-players", blacklist.end());
391 }390 }
392391
393 private void remove_from_blacklist ()392 private void remove_from_blacklist()
394 {393 {
395 var already_bl = this.settings.get_strv ("blacklisted-media-players");394 var blacklist = new GLib.VariantBuilder(new VariantType("as"));
396 var new_bl = new ArrayList<string>();395 foreach (var already_blacklisted in this.settings.get_strv("blacklisted-media-players"))
397 foreach (string s in already_bl){396 {
398 if ( s == get_blacklist_name() )continue;397 if (already_blacklisted == get_blacklist_name())
399 new_bl.add(s);398 continue;
399 blacklist.add(already_blacklisted);
400 }400 }
401 this.settings.set_strv( "blacklisted-media-players",401 this.settings.set_value("blacklisted-media-players", blacklist.end());
402 new_bl.to_array());
403 }402 }
404 }403 }
405 /****************************************************************************************/404 /****************************************************************************************/
406405
=== modified file 'test/vala/Makefile.am'
--- test/vala/Makefile.am 2012-09-26 08:45:52 +0000
+++ test/vala/Makefile.am 2012-11-07 08:48:20 +0000
@@ -2,57 +2,57 @@
22
3DISTCHECK_CONFIGURE_FLAGS = --enable-integration-tests=no3DISTCHECK_CONFIGURE_FLAGS = --enable-integration-tests=no
44
5check_PROGRAMS = test-vala test-lens test-remote-scope5check_PROGRAMS = test-vala test-lens test-remote-scope test-blacklist-crash
66
7AM_CPPFLAGS = \7AM_CPPFLAGS = \
8 -I$(top_srcdir) \8 -I$(top_srcdir) \
9 -I$(top_builddir)/protocol \9 -I$(top_builddir)/protocol \
10 -I$(top_builddir)/src \10 -I$(top_builddir)/src \
11 -DBUILDDIR=\"$(top_builddir)\" \11 -DBUILDDIR=\"$(top_builddir)\" \
12 -DTESTDIR=\"$(top_srcdir)/test\" \12 -DTESTDIR=\"$(top_srcdir)/test\" \
13 -DTESTVALADIR=\"$(top_srcdir)/test/vala\" \13 -DTESTVALADIR=\"$(top_srcdir)/test/vala\" \
14 -DG_SETTINGS_ENABLE_BACKEND \14 -DG_SETTINGS_ENABLE_BACKEND \
15 $(LIBUNITY_CFLAGS) \15 $(LIBUNITY_CFLAGS) \
16 $(LIBUNITY_LIBS)16 $(LIBUNITY_LIBS)
1717
18if !ENABLE_C_WARNINGS18if ENABLE_C_WARNINGS
19 AM_CPPFLAGS += -w19 AM_CPPFLAGS += -w
20endif20endif
2121
22if ENABLE_TRACE_LOG22if ENABLE_TRACE_LOG
23 AM_CPPFLAGS += -DENABLE_UNITY_TRACE_LOG23 AM_CPPFLAGS += -DENABLE_UNITY_TRACE_LOG
24endif24endif
2525
26AM_VALAFLAGS = \26AM_VALAFLAGS = \
27 --vapidir=$(top_builddir)/src \27 --vapidir=$(top_builddir)/src \
28 --vapidir=$(top_builddir)/protocol \28 --vapidir=$(top_builddir)/protocol \
29 --vapidir=$(top_srcdir)/test/vala \29 --vapidir=$(top_srcdir)/test/vala \
30 --pkg unity-protocol \30 --pkg unity-protocol \
31 --pkg unity-internal \31 --pkg unity-internal \
32 --pkg config \32 --pkg config \
33 $(LIBUNITY_PACKAGES) \33 $(LIBUNITY_PACKAGES) \
34 $(MAINTAINER_VALAFLAGS) \34 $(MAINTAINER_VALAFLAGS) \
35 $(NULL)35 $(NULL)
3636
37test_libs = \37test_libs = \
38 $(top_builddir)/src/libunity.la \38 $(top_builddir)/src/libunity.la \
39 $(top_builddir)/protocol/libunity-protocol-private.la \39 $(top_builddir)/protocol/libunity-protocol-private.la \
40 $(LIBUNITY_LIBS)40 $(LIBUNITY_LIBS)
4141
42TEST_PROGS += test-vala test-lens42TEST_PROGS += test-vala test-lens test-blacklist-crash
4343
44test_vala_LDADD = $(test_libs)44test_vala_LDADD = $(test_libs)
4545
46test_vala_VALASOURCES = \46test_vala_VALASOURCES = \
47 test-appinfo-manager.vala \47 test-appinfo-manager.vala \
48 test-filters.vala \48 test-filters.vala \
49 test-io.vala \49 test-io.vala \
50 test-launcher.vala \50 test-launcher.vala \
51 test-preferences.vala \51 test-preferences.vala \
52 test-previews.vala \52 test-previews.vala \
53 test-scope-signals.vala \53 test-scope-signals.vala \
54 test-vala.vala \54 test-vala.vala \
55 $(NULL)55 $(NULL)
56nodist_test_vala_SOURCES = $(test_vala_VALASOURCES:.vala=.c)56nodist_test_vala_SOURCES = $(test_vala_VALASOURCES:.vala=.c)
5757
58test_lens_LDADD = $(test_libs)58test_lens_LDADD = $(test_libs)
@@ -63,11 +63,16 @@
63test_remote_scope_VALASOURCES = test-remote-scope.vala63test_remote_scope_VALASOURCES = test-remote-scope.vala
64nodist_test_remote_scope_SOURCES = $(test_remote_scope_VALASOURCES:.vala=.c)64nodist_test_remote_scope_SOURCES = $(test_remote_scope_VALASOURCES:.vala=.c)
6565
66test_blacklist_crash_LDADD = $(test_libs)
67test_blacklist_crash_VALASOURCES = blacklist-crash-1029949-test-case.vala
68nodist_test_blacklist_crash_SOURCES = $(test_blacklist_crash_VALASOURCES:.vala=.c)
69
66BUILT_SOURCES = \70BUILT_SOURCES = \
67 test-vala.vala.stamp \71 test-vala.vala.stamp \
68 test-lens.vala.stamp \72 test-lens.vala.stamp \
69 test-remote-scope.vala.stamp \73 test-remote-scope.vala.stamp \
70 $(NULL)74 test-blacklist-crash.vala.stamp \
75 $(NULL)
7176
72test-vala.vala.stamp: $(test_vala_VALASOURCES)77test-vala.vala.stamp: $(test_vala_VALASOURCES)
73 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^78 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
@@ -81,21 +86,27 @@
81 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^86 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
82 @touch $@87 @touch $@
8388
89test-blacklist-crash.vala.stamp: $(test_blacklist_crash_VALASOURCES)
90 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
91 @touch $@
92
84include Makefile.integration_tests93include Makefile.integration_tests
8594
86EXTRA_DIST += \95EXTRA_DIST += \
87 $(test_vala_VALASOURCES) \96 $(test_vala_VALASOURCES) \
88 $(test_lens_VALASOURCES) \97 $(test_lens_VALASOURCES) \
89 $(test_remote_scope_VALASOURCES) \98 $(test_remote_scope_VALASOURCES) \
90 config.vapi \99 $(test_blacklist_crash_VALASOURCES) \
91 $(NULL)100 config.vapi \
101 $(NULL)
92102
93CLEANFILES = \103CLEANFILES = \
94 *.stamp \104 *.stamp \
95 $(test_vala_VALASOURCES:.vala=.c) \105 $(test_vala_VALASOURCES:.vala=.c) \
96 $(test_lens_VALASOURCES:.vala=.c) \106 $(test_lens_VALASOURCES:.vala=.c) \
97 $(test_remote_scope_VALASOURCES:.vala=.c) \107 $(test_remote_scope_VALASOURCES:.vala=.c) \
98 $(NULL)108 $(test_blacklist_crash_VALASOURCES:.vala=.c) \
109 $(NULL)
99110
100# START HEADLESS TESTS111# START HEADLESS TESTS
101if ENABLE_HEADLESS_TESTS112if ENABLE_HEADLESS_TESTS
102113
=== modified file 'test/vala/Makefile.integration_tests'
--- test/vala/Makefile.integration_tests 2012-08-07 12:31:44 +0000
+++ test/vala/Makefile.integration_tests 2012-11-07 08:48:20 +0000
@@ -139,4 +139,3 @@
139test-mpris-backend-prop-updates-server.vala.stamp: $(test_mpris_backend_prop_updates_server_VALASOURCES)139test-mpris-backend-prop-updates-server.vala.stamp: $(test_mpris_backend_prop_updates_server_VALASOURCES)
140 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^140 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
141 @touch $@141 @touch $@
142
143142
=== added file 'test/vala/blacklist-crash-1029949-test-case.vala'
--- test/vala/blacklist-crash-1029949-test-case.vala 1970-01-01 00:00:00 +0000
+++ test/vala/blacklist-crash-1029949-test-case.vala 2012-11-07 08:48:20 +0000
@@ -0,0 +1,44 @@
1using Gee;
2using Unity;
3
4
5
6int main(string[] args)
7{
8 int i = 0;
9 var loop = new MainLoop();
10 var time = new TimeoutSource(10);
11 MusicPlayer test_player = null;
12
13 time.set_callback(() => {
14 const string desktop_file_name = "rhythmbox.desktop";
15 test_player = new MusicPlayer(desktop_file_name);
16 test_player.export();
17
18 return false;
19 });
20 time.attach(loop.get_context());
21
22 var thread_timer = new TimeoutSource(100);
23 thread_timer.set_callback(() => {
24 set_blacklisted(test_player);
25 if (++i < 100)
26 return true;
27 test_player.unexport();
28 loop.quit();
29 return false;
30 });
31 thread_timer.attach(loop.get_context());
32
33 loop.run();
34
35 return 0;
36}
37
38void* set_blacklisted(MusicPlayer test_player)
39{
40 int raw_blacklist = Random.int_range(0, 2);
41 bool blacklist = (bool) raw_blacklist;
42 test_player.is_blacklisted = blacklist;
43 return null;
44}
045
=== modified file 'test/vala/test-mpris-backend-server.vala'
--- test/vala/test-mpris-backend-server.vala 2011-11-25 12:13:04 +0000
+++ test/vala/test-mpris-backend-server.vala 2012-11-07 08:48:20 +0000
@@ -16,6 +16,9 @@
1616
17 public bool escape ()17 public bool escape ()
18 {18 {
19 // this is some cleanup
20 this.player.menu_player.is_blacklisted = false;
21
19 this.mainloop.quit ();22 this.mainloop.quit ();
20 return false;23 return false;
21 }24 }
@@ -73,6 +76,8 @@
73 player.menu_player.player_menu = player_root;76 player.menu_player.player_menu = player_root;
7477
75 player.menu_player.add_playlist (pl2);78 player.menu_player.add_playlist (pl2);
79
80 Timeout.add (5, blacklist_self);
76 81
77 //The manual test of the playlistchanged signal, please leave commented82 //The manual test of the playlistchanged signal, please leave commented
78 //Timeout.add (5, change_playlist_name); 83 //Timeout.add (5, change_playlist_name);
@@ -81,6 +86,13 @@
81 return false;86 return false;
82 }87 }
8388
89 // Regression test to ensure that setting blacklist does not cause a segfault
90 public bool blacklist_self()
91 {
92 this.player.menu_player.is_blacklisted = true;
93 return false;
94 }
95
84 // Manual test of the playlist name change signal96 // Manual test of the playlist name change signal
85 // Can't test this from the other side of dbus since there is no api to change97 // Can't test this from the other side of dbus since there is no api to change
86 // or edit playlists yet ...98 // or edit playlists yet ...

Subscribers

People subscribed via source and target branches

to all changes: