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

Proposed by Khurshid Alam
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 Approve
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.
Revision history for this message
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

Use non-const for mime_type and free it as well

Revision history for this message
Khurshid Alam (khurshid-alam) wrote :

Right, now Fixed.

Revision history for this message
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
=== modified file 'panels/appearance/cc-appearance-panel.c'
--- panels/appearance/cc-appearance-panel.c 2017-07-18 16:31:27 +0000
+++ panels/appearance/cc-appearance-panel.c 2018-12-03 16:12:45 +0000
@@ -1285,7 +1285,7 @@
1285 if (uri)1285 if (uri)
1286 {1286 {
1287 GdkPixbuf *pixbuf = NULL;1287 GdkPixbuf *pixbuf = NULL;
1288 const gchar *mime_type = NULL;1288 char *mime_type = NULL;
1289 GFile *file;1289 GFile *file;
1290 GFileInfo *file_info;1290 GFileInfo *file_info;
1291 GtkWidget *preview;1291 GtkWidget *preview;
@@ -1300,7 +1300,7 @@
1300 g_object_unref (file);1300 g_object_unref (file);
13011301
1302 if (file_info != NULL) {1302 if (file_info != NULL) {
1303 mime_type = g_file_info_get_content_type (file_info);1303 mime_type = g_strdup (g_file_info_get_content_type (file_info));
1304 g_object_unref (file_info);1304 g_object_unref (file_info);
1305 }1305 }
13061306
@@ -1309,6 +1309,7 @@
1309 pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumb_factory,1309 pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumb_factory,
1310 uri,1310 uri,
1311 mime_type);1311 mime_type);
1312 g_free (mime_type);
1312 }1313 }
13131314
1314 gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser),1315 gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser),
13151316
=== modified file 'panels/user-accounts/um-photo-dialog.c'
--- panels/user-accounts/um-photo-dialog.c 2014-02-21 15:48:18 +0000
+++ panels/user-accounts/um-photo-dialog.c 2018-12-03 16:12:45 +0000
@@ -163,7 +163,7 @@
163163
164 if (uri) {164 if (uri) {
165 GdkPixbuf *pixbuf = NULL;165 GdkPixbuf *pixbuf = NULL;
166 const gchar *mime_type = NULL;166 char *mime_type = NULL;
167 GFile *file;167 GFile *file;
168 GFileInfo *file_info;168 GFileInfo *file_info;
169 GtkWidget *preview;169 GtkWidget *preview;
@@ -178,7 +178,7 @@
178 g_object_unref (file);178 g_object_unref (file);
179179
180 if (file_info != NULL) {180 if (file_info != NULL) {
181 mime_type = g_file_info_get_content_type (file_info);181 mime_type = g_strdup (g_file_info_get_content_type (file_info));
182 g_object_unref (file_info);182 g_object_unref (file_info);
183 }183 }
184184
@@ -186,6 +186,7 @@
186 pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumb_factory,186 pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumb_factory,
187 uri,187 uri,
188 mime_type);188 mime_type);
189 g_free (mime_type);
189 }190 }
190191
191 gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser),192 gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser),

Subscribers

People subscribed via source and target branches