Merge lp:~gordallott/unity/fix-missing-icons into lp:unity

Proposed by Gord Allott
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 1558
Proposed branch: lp:~gordallott/unity/fix-missing-icons
Merge into: lp:unity
Diff against target: 50 lines (+14/-5)
2 files modified
plugins/unityshell/src/IconLoader.cpp (+1/-0)
plugins/unityshell/src/ResultRendererTile.cpp (+13/-5)
To merge this branch: bzr merge lp:~gordallott/unity/fix-missing-icons
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+74973@code.launchpad.net

Description of the change

fix for lp:830887 hopefully

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Gord, afaics this introduces an new stat() call *every time* we load an icon - even if we've already cached it in the icon loader.

review: Needs Fixing
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

I'd propose fixing the icon loader - also taking into account that the icon loader can cache the fact that a file doesn't exist. I've done similarly with .desktop files in libunity's Unity.AppInfoManager.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

r1529 discussed on irc

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/IconLoader.cpp'
2--- plugins/unityshell/src/IconLoader.cpp 2011-09-05 00:46:13 +0000
3+++ plugins/unityshell/src/IconLoader.cpp 2011-09-14 10:24:24 +0000
4@@ -507,6 +507,7 @@
5 {
6 LOG_WARNING(logger) << "Unable to load contents of "
7 << task->data << ": " << error;
8+ task->slot(task->data, task->size, nullptr);
9 }
10 task->self->task_map_.erase(task->handle);
11 delete task;
12
13=== modified file 'plugins/unityshell/src/ResultRendererTile.cpp'
14--- plugins/unityshell/src/ResultRendererTile.cpp 2011-09-13 22:35:13 +0000
15+++ plugins/unityshell/src/ResultRendererTile.cpp 2011-09-14 10:24:24 +0000
16@@ -262,12 +262,13 @@
17 }
18 g_free(tmp5);
19
20+
21 GIcon* icon = g_icon_new_for_string(icon_name.c_str(), NULL);
22 TextureContainer* container = row.renderer<TextureContainer*>();
23
24 IconLoader::IconLoaderCallback slot = sigc::bind(sigc::mem_fun(this, &ResultRendererTile::IconLoaded), icon_hint, row);
25
26- if (g_str_has_prefix(icon_name.c_str(), "http://"))
27+ if (g_strrstr(icon_name.c_str(), "://"))
28 {
29 container->slot_handle = IconLoader::GetDefault().LoadFromURI(icon_name.c_str(), 48, slot);
30 }
31@@ -335,10 +336,17 @@
32 container->blurred_icon = texture_blurred;
33
34 NeedsRedraw.emit();
35- }
36- // Whether there is a pixbuf or not, we need to clear the slot_handle.
37- if (container)
38- container->slot_handle = 0;
39+
40+ if (container)
41+ container->slot_handle = 0;
42+ }
43+ else
44+ {
45+ // we need to load a missing icon
46+ IconLoader::IconLoaderCallback slot = sigc::bind(sigc::mem_fun(this, &ResultRendererTile::IconLoaded), icon_name, row);
47+ container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(". GThemedIcon text-x-preview", 48, slot);
48+ }
49+
50 }
51
52