Merge lp:~khurshid-alam/unity-control-center/fix-image-preview into lp:unity-control-center

Proposed by Khurshid Alam on 2018-11-30
Status: Merged
Merged at revision: 12917
Proposed branch: lp:~khurshid-alam/unity-control-center/fix-image-preview
Merge into: lp:unity-control-center
Diff against target: 59 lines (+6/-4)
2 files modified
panels/appearance/cc-appearance-panel.c (+3/-2)
panels/user-accounts/um-photo-dialog.c (+3/-2)
To merge this branch: bzr merge lp:~khurshid-alam/unity-control-center/fix-image-preview
Reviewer Review Type Date Requested Status
Sebastien Bacher 2018-11-30 Approve on 2018-12-03
Review via email: mp+359937@code.launchpad.net

Commit message

Fix image preview in GtkFileChooser

g_file_info_get_content_type() returns an internal string, and we were
freeing the file_info we got it from in the next line, so it's a miracle
that the mime_type was ever not garbage.

See https://bugzilla.gnome.org/show_bug.cgi?id=778424

To post a comment you must log in.
Sebastien Bacher (seb128) wrote :

Thank you for your work

The corresponding upstream change for the user panel is
https://gitlab.gnome.org/GNOME/gnome-control-center/commit/5c5d6087

Why didn't you take the other parts of the change? The "non-const" seems needed since now mime_type is the return of a g_strdup. The free call is also needed otherwise you leak the dup-ed string

The appareance capplet code is in the same case

review: Needs Fixing
12916. By Khurshid Alam on 2018-12-03

Use non-const for mime_type and free it as well

Khurshid Alam (khurshid-alam) wrote :

Right, now Fixed.

Sebastien Bacher (seb128) wrote :

that's better, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panels/appearance/cc-appearance-panel.c'
2--- panels/appearance/cc-appearance-panel.c 2017-07-18 16:31:27 +0000
3+++ panels/appearance/cc-appearance-panel.c 2018-12-03 16:12:45 +0000
4@@ -1285,7 +1285,7 @@
5 if (uri)
6 {
7 GdkPixbuf *pixbuf = NULL;
8- const gchar *mime_type = NULL;
9+ char *mime_type = NULL;
10 GFile *file;
11 GFileInfo *file_info;
12 GtkWidget *preview;
13@@ -1300,7 +1300,7 @@
14 g_object_unref (file);
15
16 if (file_info != NULL) {
17- mime_type = g_file_info_get_content_type (file_info);
18+ mime_type = g_strdup (g_file_info_get_content_type (file_info));
19 g_object_unref (file_info);
20 }
21
22@@ -1309,6 +1309,7 @@
23 pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumb_factory,
24 uri,
25 mime_type);
26+ g_free (mime_type);
27 }
28
29 gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser),
30
31=== modified file 'panels/user-accounts/um-photo-dialog.c'
32--- panels/user-accounts/um-photo-dialog.c 2014-02-21 15:48:18 +0000
33+++ panels/user-accounts/um-photo-dialog.c 2018-12-03 16:12:45 +0000
34@@ -163,7 +163,7 @@
35
36 if (uri) {
37 GdkPixbuf *pixbuf = NULL;
38- const gchar *mime_type = NULL;
39+ char *mime_type = NULL;
40 GFile *file;
41 GFileInfo *file_info;
42 GtkWidget *preview;
43@@ -178,7 +178,7 @@
44 g_object_unref (file);
45
46 if (file_info != NULL) {
47- mime_type = g_file_info_get_content_type (file_info);
48+ mime_type = g_strdup (g_file_info_get_content_type (file_info));
49 g_object_unref (file_info);
50 }
51
52@@ -186,6 +186,7 @@
53 pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumb_factory,
54 uri,
55 mime_type);
56+ g_free (mime_type);
57 }
58
59 gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser),

Subscribers

People subscribed via source and target branches