Merge lp:~mhr3/unity/a-few-fixes into lp:unity

Proposed by Michal Hruby
Status: Merged
Approved by: Michal Hruby
Approved revision: no longer in the source branch.
Merged at revision: 2285
Proposed branch: lp:~mhr3/unity/a-few-fixes
Merge into: lp:unity
Diff against target: 64 lines (+13/-7)
4 files modified
UnityCore/GLibSignal.cpp (+1/-1)
UnityCore/Hud.cpp (+5/-5)
plugins/unityshell/src/DebugDBusInterface.cpp (+2/-1)
plugins/unityshell/src/PanelMenuView.cpp (+5/-0)
To merge this branch: bzr merge lp:~mhr3/unity/a-few-fixes
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+102094@code.launchpad.net

Commit message

Fix a couple of wrong reference/memory management issues

Description of the change

Fix a couple of possible crashes:

1) The debug interface was unreferencing a variant that it didn't own
2) Hud was freeing strings that g_variant_iter_loop frees itself
3) PanelMenuView was disconnecting signal on an object that could be already dead

As for tests, the hud AP tests were crashing without these fixes, now unity survives them :)

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

Looks good to me ;)

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

No commit message specified.

Revision history for this message
Tim Penhey (thumper) wrote :

\o/ you guys rock

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/GLibSignal.cpp'
2--- UnityCore/GLibSignal.cpp 2011-07-21 14:59:25 +0000
3+++ UnityCore/GLibSignal.cpp 2012-04-16 12:19:19 +0000
4@@ -36,7 +36,7 @@
5
6 void SignalBase::Disconnect()
7 {
8- if (G_IS_OBJECT(object_) && connection_id_)
9+ if (connection_id_ && G_IS_OBJECT(object_))
10 g_signal_handler_disconnect(object_, connection_id_);
11
12 object_ = 0;
13
14=== modified file 'UnityCore/Hud.cpp'
15--- UnityCore/Hud.cpp 2012-04-04 23:39:38 +0000
16+++ UnityCore/Hud.cpp 2012-04-16 12:19:19 +0000
17@@ -159,11 +159,11 @@
18 {
19 GVariantIter iter;
20 g_variant_iter_init(&iter, query_array);
21- glib::String formatted_text;
22- glib::String icon;
23- glib::String item_icon;
24- glib::String completion_text;
25- glib::String shortcut;
26+ gchar* formatted_text;
27+ gchar* icon;
28+ gchar* item_icon;
29+ gchar* completion_text;
30+ gchar* shortcut;
31 GVariant* key = NULL;
32
33 while (g_variant_iter_loop(&iter, "(sssssv)",
34
35=== modified file 'plugins/unityshell/src/DebugDBusInterface.cpp'
36--- plugins/unityshell/src/DebugDBusInterface.cpp 2012-03-21 12:31:11 +0000
37+++ plugins/unityshell/src/DebugDBusInterface.cpp 2012-04-16 12:19:19 +0000
38@@ -177,8 +177,9 @@
39 g_variant_get(parameters, "(&s)", &input);
40
41 ret = GetState(input);
42+ // GetState returns a floating variant and
43+ // g_dbus_method_invocation_return_value ref sinks it
44 g_dbus_method_invocation_return_value(invocation, ret);
45- g_variant_unref(ret);
46 }
47 else if (g_strcmp0(method_name, "StartLogToFile") == 0)
48 {
49
50=== modified file 'plugins/unityshell/src/PanelMenuView.cpp'
51--- plugins/unityshell/src/PanelMenuView.cpp 2012-04-11 00:37:25 +0000
52+++ plugins/unityshell/src/PanelMenuView.cpp 2012-04-16 12:19:19 +0000
53@@ -983,6 +983,11 @@
54
55 void PanelMenuView::OnViewClosed(BamfMatcher *matcher, BamfView *view)
56 {
57+ if (reinterpret_cast<BamfView*>(_view_name_changed_signal.object()) == view)
58+ {
59+ _view_name_changed_signal.Disconnect();
60+ }
61+
62 if (BAMF_IS_APPLICATION(view))
63 {
64 OnApplicationClosed(reinterpret_cast<BamfApplication*>(view));