comparison pidgin/gtkprefs.c @ 32138:e2c6e4fc3c84

Start looking at the GError parameter every time we call these functions: - gdk_pixbuf_loader_write - gdk_pixbuf_loader_close - gdk_pixbuf_new_from_file - gdk_pixbuf_new_from_file_at_size - gdk_pixbuf_new_from_file_at_scale There are times when gdkpixbuf returns a semi-invalid GdkPixbuf object and also sets the GError. If this happens we want to discard and ignore the GdkPixbuf object because it can cause problems. For example, calling gdk_pixbuf_scale_simple() causes gdkpixbuf to rapidly consume memory in an infinite loop. And that's bad. This commit adds some helper functions to gtkutils.[c|h] that make it a little easier to check the GError value. We should use them everywhere we call any of the above functions.
author Mark Doliner <mark@kingant.net>
date Wed, 22 Jun 2011 07:07:28 +0000
parents 8b434ffd4efc
children accce7b79737 a8f62638417e
comparison
equal deleted inserted replaced
32135:ec1e6b5893a0 32138:e2c6e4fc3c84
380 380
381 /* 381 /*
382 * LEAK - Gentoo memprof thinks pixbuf is leaking here... but it 382 * LEAK - Gentoo memprof thinks pixbuf is leaking here... but it
383 * looks like it should be ok to me. Anyone know what's up? --Mark 383 * looks like it should be ok to me. Anyone know what's up? --Mark
384 */ 384 */
385 pixbuf = (theme->icon ? gdk_pixbuf_new_from_file(theme->icon, NULL) : NULL); 385 pixbuf = (theme->icon ? pidgin_pixbuf_new_from_file(theme->icon) : NULL);
386 386
387 gtk_list_store_set(prefs_smiley_themes, &iter, 387 gtk_list_store_set(prefs_smiley_themes, &iter,
388 0, pixbuf, 388 0, pixbuf,
389 1, description, 389 1, description,
390 2, theme->name, 390 2, theme->name,
450 450
451 if (PURPLE_IS_SOUND_THEME(theme)){ 451 if (PURPLE_IS_SOUND_THEME(theme)){
452 452
453 image_full = purple_theme_get_image_full(theme); 453 image_full = purple_theme_get_image_full(theme);
454 if (image_full != NULL){ 454 if (image_full != NULL){
455 pixbuf = gdk_pixbuf_new_from_file_at_scale(image_full, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE, TRUE, NULL); 455 pixbuf = pidgin_pixbuf_new_from_file_at_scale(image_full, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE, TRUE);
456 g_free(image_full); 456 g_free(image_full);
457 } else 457 } else
458 pixbuf = NULL; 458 pixbuf = NULL;
459 459
460 gtk_list_store_append(prefs_sound_themes, &iter); 460 gtk_list_store_append(prefs_sound_themes, &iter);
471 else 471 else
472 store = prefs_status_icon_themes; 472 store = prefs_status_icon_themes;
473 473
474 image_full = purple_theme_get_image_full(theme); 474 image_full = purple_theme_get_image_full(theme);
475 if (image_full != NULL){ 475 if (image_full != NULL){
476 pixbuf = gdk_pixbuf_new_from_file_at_scale(image_full, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE, TRUE, NULL); 476 pixbuf = pidgin_pixbuf_new_from_file_at_scale(image_full, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE, TRUE);
477 g_free(image_full); 477 g_free(image_full);
478 } else 478 } else
479 pixbuf = NULL; 479 pixbuf = NULL;
480 480
481 name = purple_theme_get_name(theme); 481 name = purple_theme_get_name(theme);
527 prefs_sound_themes_loading = TRUE; 527 prefs_sound_themes_loading = TRUE;
528 /* refresh the list of themes in the manager */ 528 /* refresh the list of themes in the manager */
529 purple_theme_manager_refresh(); 529 purple_theme_manager_refresh();
530 530
531 tmp = g_build_filename(DATADIR, "icons", "hicolor", "32x32", "apps", "pidgin.png", NULL); 531 tmp = g_build_filename(DATADIR, "icons", "hicolor", "32x32", "apps", "pidgin.png", NULL);
532 pixbuf = gdk_pixbuf_new_from_file_at_scale(tmp, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE, TRUE, NULL); 532 pixbuf = pidgin_pixbuf_new_from_file_at_scale(tmp, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE, TRUE);
533 g_free(tmp); 533 g_free(tmp);
534 534
535 /* sound themes */ 535 /* sound themes */
536 gtk_list_store_clear(prefs_sound_themes); 536 gtk_list_store_clear(prefs_sound_themes);
537 gtk_list_store_append(prefs_sound_themes, &iter); 537 gtk_list_store_append(prefs_sound_themes, &iter);