Skip to content

Commit 51fe36d

Browse files
committed
gnome-desktop-thumbnailer.c: Make sure a thumbnailer's binary is
found in the path before deciding to use it. This would cause an invalid thumbnailer to prevent a valid one from registering, breaking thumbnailing for those mimetypes until the invalid one was fixed or removed. ref: linuxmint/linuxmint#452
1 parent 854f16a commit 51fe36d

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

libcinnamon-desktop/gnome-desktop-thumbnail.c

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,20 @@ thumbnailer_load (Thumbnailer *thumb)
178178
}
179179

180180
thumb->try_exec = g_key_file_get_string (key_file, THUMBNAILER_ENTRY_GROUP, "TryExec", NULL);
181+
if (thumb->try_exec != NULL)
182+
{
183+
gchar *path_to_exec = g_find_program_in_path (thumb->try_exec);
184+
185+
if (path_to_exec == NULL)
186+
{
187+
g_message ("Ignoring thumbnailer with missing binary: '%s'", thumb->try_exec);
188+
thumbnailer_unref (thumb);
189+
g_key_file_free (key_file);
190+
return NULL;
191+
}
192+
193+
g_free (path_to_exec);
194+
}
181195

182196
g_key_file_free (key_file);
183197

@@ -211,28 +225,6 @@ thumbnailer_new (const gchar *path)
211225
return thumbnailer_load (thumb);
212226
}
213227

214-
static gboolean
215-
thumbnailer_try_exec (Thumbnailer *thumb)
216-
{
217-
gchar *path;
218-
gboolean retval;
219-
220-
if (G_UNLIKELY (!thumb))
221-
return FALSE;
222-
223-
/* TryExec is optinal, but Exec isn't, so we assume
224-
* the thumbnailer can be run when TryExec is not present
225-
*/
226-
if (!thumb->try_exec)
227-
return TRUE;
228-
229-
path = g_find_program_in_path (thumb->try_exec);
230-
retval = path != NULL;
231-
g_free (path);
232-
233-
return retval;
234-
}
235-
236228
static gpointer
237229
init_thumbnailers_dirs (gpointer data)
238230
{
@@ -1087,9 +1079,6 @@ gnome_desktop_thumbnail_factory_can_thumbnail (GnomeDesktopThumbnailFactory *fac
10871079
const char *mime_type,
10881080
time_t mtime)
10891081
{
1090-
gboolean have_script = FALSE;
1091-
1092-
10931082
if (factory->priv->permissions_problem)
10941083
return FALSE;
10951084

@@ -1111,11 +1100,10 @@ gnome_desktop_thumbnail_factory_can_thumbnail (GnomeDesktopThumbnailFactory *fac
11111100

11121101
Thumbnailer *thumb;
11131102
thumb = g_hash_table_lookup (factory->priv->mime_types_map, mime_type);
1114-
have_script = thumbnailer_try_exec (thumb);
11151103

11161104
g_mutex_unlock (&factory->priv->lock);
11171105

1118-
if (have_script || mimetype_supported_by_gdk_pixbuf (mime_type))
1106+
if (thumb || mimetype_supported_by_gdk_pixbuf (mime_type))
11191107
{
11201108
return !gnome_desktop_thumbnail_factory_has_valid_failed_thumbnail (factory,
11211109
uri,

0 commit comments

Comments
 (0)