Merge lp:~unity-team/unity/unity.fix-sc-icon-to-launcher-animation-981168 into lp:unity

Proposed by Jay Taoko
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 2367
Proposed branch: lp:~unity-team/unity/unity.fix-sc-icon-to-launcher-animation-981168
Merge into: lp:unity
Diff against target: 120 lines (+47/-18)
2 files modified
launcher/Launcher.cpp (+36/-18)
launcher/Launcher.h (+11/-0)
To merge this branch: bzr merge lp:~unity-team/unity/unity.fix-sc-icon-to-launcher-animation-981168
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Review via email: mp+102239@code.launchpad.net

Commit message

* Capture information about the icon of the application to be installed from the software center. Re-use it when rendering the launcher interface.
* Fix bug #981168

Description of the change

* Capture information about the icon of the application to be installed from the software center. Re-use it when rendering the launcher interface.
* Fix bug #981168

UNBLOCK

To post a comment you must log in.
Revision history for this message
Gord Allott (gordallott) wrote :

just a quick fix needed on this branch,
first the we need to g_free the _sc_* pointers in the destructor

Then secondly, in this code, after g_free'ing the pointers the pointers should be set to NULL:

25 +
26 + if (_sc_anim_icon)
27 + {
28 + launcher_addrequest_special.emit(_sc_icon_desktop_file, AbstractLauncherIcon::Ptr(), _sc_icon_aptdaemon_task, _sc_icon, _sc_icon_x, _sc_icon_y, _sc_icon_size);
29 + g_free(_sc_icon);
30 + g_free(_sc_icon_title);
31 + g_free(_sc_icon_desktop_file);
32 + g_free(_sc_icon_aptdaemon_task);
33 + _sc_anim_icon = false;
34 + }

Then thirdly, before this code we should be g_free'ing the pointers to ensure there is no possible memory leak

58 + self->_sc_anim_icon = true;
59 + g_variant_get(parameters, "(ssiiiss)", &self->_sc_icon_title,
60 + &self->_sc_icon,
61 + &self->_sc_icon_x,
62 + &self->_sc_icon_y,
63 + &self->_sc_icon_size,
64 + &self->_sc_icon_desktop_file,
65 + &self->_sc_icon_aptdaemon_task, NULL);

Other than that, looks good to me

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

My thoughts were around why not use glib::String objects?

Revision history for this message
Gord Allott (gordallott) wrote :

fixed up myself..

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/Launcher.cpp'
2--- launcher/Launcher.cpp 2012-05-15 19:33:20 +0000
3+++ launcher/Launcher.cpp 2012-05-24 10:26:20 +0000
4@@ -294,6 +294,16 @@
5 launcher_pressure_effect_ = cache.FindTexture("launcher_pressure_effect", 0, 0, cb);
6
7 options.changed.connect (sigc::mem_fun (this, &Launcher::OnOptionsChanged));
8+
9+ // icon information from software center
10+ _sc_icon = NULL;
11+ _sc_icon_title = NULL;
12+ _sc_icon_x = 0;
13+ _sc_icon_y = 0;
14+ _sc_icon_size = 0;
15+ _sc_icon_desktop_file = NULL;
16+ _sc_icon_aptdaemon_task = NULL;
17+ _sc_anim_icon = false;
18 }
19
20 Launcher::~Launcher()
21@@ -321,6 +331,11 @@
22
23 delete _hover_machine;
24 delete _hide_machine;
25+
26+ g_free(_sc_icon);
27+ g_free(_sc_icon_title);
28+ g_free(_sc_icon_desktop_file);
29+ g_free(_sc_icon_aptdaemon_task);
30 }
31
32 /* Introspection */
33@@ -2087,6 +2102,16 @@
34 gPainter.PopBackground(push_count);
35 GfxContext.PopClippingRectangle();
36 GfxContext.PopClippingRectangle();
37+
38+ if (_sc_anim_icon)
39+ {
40+ launcher_addrequest_special.emit(_sc_icon_desktop_file, AbstractLauncherIcon::Ptr(), _sc_icon_aptdaemon_task, _sc_icon, _sc_icon_x, _sc_icon_y, _sc_icon_size);
41+ g_free(_sc_icon); _sc_icon = NULL;
42+ g_free(_sc_icon_title); _sc_icon_title = NULL;
43+ g_free(_sc_icon_desktop_file); _sc_icon_desktop_file = NULL;
44+ g_free(_sc_icon_aptdaemon_task); _sc_icon_aptdaemon_task = NULL;
45+ _sc_anim_icon = false;
46+ }
47 }
48
49 void Launcher::PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw)
50@@ -2951,30 +2976,23 @@
51 GDBusMethodInvocation* invocation,
52 gpointer user_data)
53 {
54-
55 if (g_strcmp0(method_name, "AddLauncherItemFromPosition") == 0)
56 {
57- gchar* icon;
58- gchar* title;
59- gint32 icon_x;
60- gint32 icon_y;
61- gint32 icon_size;
62- gchar* desktop_file;
63- gchar* aptdaemon_task;
64-
65- g_variant_get(parameters, "(ssiiiss)", &title, &icon, &icon_x, &icon_y, &icon_size, &desktop_file, &aptdaemon_task, NULL);
66-
67 Launcher* self = (Launcher*)user_data;
68- self->launcher_addrequest_special.emit(desktop_file, AbstractLauncherIcon::Ptr(), aptdaemon_task, icon,
69- icon_x, icon_y, icon_size);
70+ self->_sc_anim_icon = true;
71+ g_free(self->_sc_icon);
72+ g_free(self->_sc_icon_desktop_file);
73+ g_free(self->_sc_icon_aptdaemon_task);
74+ g_variant_get(parameters, "(ssiiiss)", &self->_sc_icon_title,
75+ &self->_sc_icon,
76+ &self->_sc_icon_x,
77+ &self->_sc_icon_y,
78+ &self->_sc_icon_size,
79+ &self->_sc_icon_desktop_file,
80+ &self->_sc_icon_aptdaemon_task, NULL);
81
82 g_dbus_method_invocation_return_value(invocation, nullptr);
83- g_free(icon);
84- g_free(title);
85- g_free(desktop_file);
86- g_free(aptdaemon_task);
87 }
88-
89 }
90
91 void
92
93=== modified file 'launcher/Launcher.h'
94--- launcher/Launcher.h 2012-05-07 19:52:54 +0000
95+++ launcher/Launcher.h 2012-05-24 10:26:20 +0000
96@@ -122,6 +122,8 @@
97 sigc::signal<void, AbstractLauncherIcon::Ptr> icon_animation_complete;
98 sigc::signal<void> selection_change;
99 sigc::signal<void> hidden_changed;
100+ sigc::signal<void> sc_launcher_icon_animation;
101+ sigc::connection sc_launcher_icon_animation_connection;
102
103 virtual bool InspectKeyEvent(unsigned int eventType,
104 unsigned int keysym,
105@@ -416,6 +418,15 @@
106
107 ui::AbstractIconRenderer::Ptr icon_renderer;
108 BackgroundEffectHelper bg_effect_helper_;
109+
110+ gchar* _sc_icon;
111+ gchar* _sc_icon_title;
112+ gint32 _sc_icon_x;
113+ gint32 _sc_icon_y;
114+ gint32 _sc_icon_size;
115+ gchar* _sc_icon_desktop_file;
116+ gchar* _sc_icon_aptdaemon_task;
117+ bool _sc_anim_icon;
118 };
119
120 }