Fixed error handling while generating thumbnails

This commit is contained in:
Pierre Pronchery 2013-10-05 02:02:14 +02:00
parent 5a65d8a741
commit b70fc2dfa7

View File

@ -1234,12 +1234,6 @@ static void _loop_insert(Browser * browser, GtkTreeIter * iter,
&ddate, &type, path, &icon24 &ddate, &type, path, &icon24
#if GTK_CHECK_VERSION(2, 6, 0) #if GTK_CHECK_VERSION(2, 6, 0)
, &icon48, &icon96); , &icon48, &icon96);
if(type != NULL && strncmp(type, "image/", 6) == 0
&& browser->loading != NULL)
{
g_object_ref(browser->loading);
icon96 = browser->loading;
}
gtk_list_store_insert_with_values(browser->store, iter, -1, gtk_list_store_insert_with_values(browser->store, iter, -1,
#else #else
, NULL, NULL); , NULL, NULL);
@ -1281,6 +1275,7 @@ static void _insert_all(Browser * browser, struct stat * lst, struct stat * st,
char const ** ddate, char const ** type, char const * path, char const ** ddate, char const ** type, char const * path,
GdkPixbuf ** icon24, GdkPixbuf ** icon48, GdkPixbuf ** icon96) GdkPixbuf ** icon24, GdkPixbuf ** icon48, GdkPixbuf ** icon96)
{ {
const char image[6] = "image/";
char const * p; char const * p;
GError * error = NULL; GError * error = NULL;
@ -1308,8 +1303,19 @@ static void _insert_all(Browser * browser, struct stat * lst, struct stat * st,
*icon48 = vfs_mime_icon(browser->mime, path, *type, lst, st, *icon48 = vfs_mime_icon(browser->mime, path, *type, lst, st,
48); 48);
if(icon96 != NULL) if(icon96 != NULL)
{
#if GTK_CHECK_VERSION(2, 6, 0)
if(*type != NULL && strncmp(*type, image, sizeof(image)) == 0
&& browser->loading != NULL)
{
g_object_ref(browser->loading);
*icon96 = browser->loading;
}
else
#endif
*icon96 = vfs_mime_icon(browser->mime, path, *type, lst, st, *icon96 = vfs_mime_icon(browser->mime, path, *type, lst, st,
96); 96);
}
} }
static char const * _insert_size(off_t size) static char const * _insert_size(off_t size)
@ -1401,8 +1407,8 @@ static gboolean _done_thumbnails(gpointer data)
char * path; char * path;
GdkPixbuf * icon; GdkPixbuf * icon;
GError * error = NULL; GError * error = NULL;
const char image[6] = "image/";
char const * p; char const * p;
char const image[6] = "image/";
for(i = 0; i < IDLE_LOOP_ICON_CNT; i++) for(i = 0; i < IDLE_LOOP_ICON_CNT; i++)
{ {
@ -1422,17 +1428,20 @@ static gboolean _done_thumbnails(gpointer data)
{ {
if((icon = gdk_pixbuf_new_from_file_at_size(path, 96, if((icon = gdk_pixbuf_new_from_file_at_size(path, 96,
96, &error)) == NULL) 96, &error)) == NULL)
{ icon = vfs_mime_icon(browser->mime, path, type,
browser_error(NULL, error->message, 1); NULL, NULL, 96);
g_error_free(error); if(icon != NULL)
error = NULL;
}
else
{ {
gtk_list_store_set(browser->store, iter, gtk_list_store_set(browser->store, iter,
BC_PIXBUF_96, icon, -1); BC_PIXBUF_96, icon, -1);
g_object_unref(icon); g_object_unref(icon);
} }
if(error != NULL)
{
browser_error(NULL, error->message, 1);
g_error_free(error);
error = NULL;
}
} }
free(type); free(type);
free(path); free(path);
@ -1577,14 +1586,6 @@ static void _loop_update(Browser * browser, GtkTreeIter * iter,
, &icon48, &icon96 , &icon48, &icon96
#endif #endif
); );
#if GTK_CHECK_VERSION(2, 6, 0)
if(type != NULL && strncmp(type, "image/", 6) == 0
&& browser->loading != NULL)
{
g_object_ref(browser->loading);
icon96 = browser->loading;
}
#endif
gtk_list_store_set(browser->store, iter, BC_UPDATED, 1, BC_PATH, path, gtk_list_store_set(browser->store, iter, BC_UPDATED, 1, BC_PATH, path,
BC_DISPLAY_NAME, display, BC_INODE, inode, BC_DISPLAY_NAME, display, BC_INODE, inode,
BC_IS_DIRECTORY, S_ISDIR(st->st_mode), BC_IS_DIRECTORY, S_ISDIR(st->st_mode),