Merge lp:~azzar1/unity/fix-772445 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2482
Proposed branch: lp:~azzar1/unity/fix-772445
Merge into: lp:unity
Diff against target: 73 lines (+28/-13)
3 files modified
launcher/DndData.cpp (+13/-12)
launcher/Launcher.cpp (+1/-1)
manual-tests/Launcher.txt (+14/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-772445
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Review via email: mp+113981@code.launchpad.net

Commit message

Fix freezes during dnd.

Description of the change

== Problem ==
Dragging image from firefox/chrome to dock causes lagg/freeze

== Fix ==
Replace g_file_info_get_content_type with g_content_type_guess.
It's less accurate but it should not be a problem: we just use it to highlight launcher icons during dnd.

== Test ==
Manual test added.

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

after consulting my glib knowledge fountains it seems g_content_type_guess should be just fine for our usage.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/DndData.cpp'
2--- launcher/DndData.cpp 2012-05-07 19:52:54 +0000
3+++ launcher/DndData.cpp 2012-07-09 17:36:26 +0000
4@@ -33,21 +33,22 @@
5 Reset();
6
7 char* pch = strtok (uris, "\r\n");
8- while (pch != NULL)
9+ while (pch)
10 {
11- glib::Object<GFile> file(g_file_new_for_uri(pch));
12- glib::Object<GFileInfo> info(g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL));
13- const char* content_type = g_file_info_get_content_type(info);
14-
15- uris_.insert(pch);
16-
17- if (content_type != NULL)
18+ glib::String content_type(g_content_type_guess(pch,
19+ nullptr,
20+ 0,
21+ nullptr));
22+
23+ if (content_type)
24 {
25- types_.insert(content_type);
26- uris_to_types_[pch] = content_type;
27- types_to_uris_[content_type].insert(pch);
28+ types_.insert(content_type.Str());
29+ uris_to_types_[pch] = content_type.Str();
30+ types_to_uris_[content_type.Str()].insert(pch);
31 }
32-
33+
34+ uris_.insert(pch);
35+
36 pch = strtok (NULL, "\r\n");
37 }
38 }
39
40=== modified file 'launcher/Launcher.cpp'
41--- launcher/Launcher.cpp 2012-06-21 06:55:53 +0000
42+++ launcher/Launcher.cpp 2012-07-09 17:36:26 +0000
43@@ -2697,7 +2697,7 @@
44 {
45 for (auto it : *_model)
46 {
47- if (it->QueryAcceptDrop(_dnd_data) != nux::DNDACTION_NONE)
48+ if (it->ShouldHighlightOnDrag(_dnd_data))
49 it->SetQuirk(AbstractLauncherIcon::QUIRK_DROP_PRELIGHT, true);
50 else
51 it->SetQuirk(AbstractLauncherIcon::QUIRK_DROP_DIM, true);
52
53=== modified file 'manual-tests/Launcher.txt'
54--- manual-tests/Launcher.txt 2012-07-06 07:38:40 +0000
55+++ manual-tests/Launcher.txt 2012-07-09 17:36:26 +0000
56@@ -592,3 +592,17 @@
57
58 Expected Results:
59 * The device launcher icon has been removed.
60+
61+
62+Drag and Drop doesn't freeze Unity
63+----------------------------------
64+Actions:
65+#. Open Firefox
66+#. Go to http://launchpad.net/unity
67+#. Drag around the Unity icon image shown in the top-left corner
68+ of the browser window.
69+#. Drop it wherever you want.
70+
71+Expected Result:
72+Unity must not freeze during the drag and drop.
73+