[gthumb] catalogs: correctly load empty catalogs
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] catalogs: correctly load empty catalogs
- Date: Mon, 27 Jan 2020 17:13:59 +0000 (UTC)
commit 85f5fc57a3b360480ec0e82a0b1052444e62a179
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Jan 20 09:56:15 2020 +0100
catalogs: correctly load empty catalogs
Do not return a null catalog if the catalog file is empty.
extensions/catalogs/dlg-catalog-properties.c | 2 +-
extensions/catalogs/gth-catalog.c | 12 +++++++++---
extensions/catalogs/gth-file-source-catalogs.c | 10 ++++------
3 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/extensions/catalogs/dlg-catalog-properties.c b/extensions/catalogs/dlg-catalog-properties.c
index b2f20f68..88c1d4d1 100644
--- a/extensions/catalogs/dlg-catalog-properties.c
+++ b/extensions/catalogs/dlg-catalog-properties.c
@@ -150,7 +150,7 @@ catalog_ready_cb (GObject *object,
{
DialogData *data = user_data;
- if ((error != NULL) || (object == NULL)) {
+ if (error != NULL) {
_gtk_error_dialog_from_gerror_show (GTK_WINDOW(data->browser), _("Could not load the
catalog"), error);
gtk_widget_destroy (data->dialog);
return;
diff --git a/extensions/catalogs/gth-catalog.c b/extensions/catalogs/gth-catalog.c
index 9d9d940a..ff310187 100644
--- a/extensions/catalogs/gth-catalog.c
+++ b/extensions/catalogs/gth-catalog.c
@@ -927,8 +927,9 @@ gth_catalog_update_standard_attributes (GFile *file,
typedef struct {
- ReadyCallback ready_func;
- gpointer user_data;
+ GFile *file;
+ ReadyCallback ready_func;
+ gpointer user_data;
} LoadData;
@@ -941,12 +942,16 @@ load__catalog_buffer_ready_cb (void **buffer,
LoadData *load_data = user_data;
GthCatalog *catalog;
- if (error == NULL)
+ if (error == NULL) {
catalog = gth_catalog_new_from_data (*buffer, count, &error);
+ if (catalog == NULL)
+ catalog = gth_catalog_new_for_file (load_data->file);
+ }
else
catalog = NULL;
load_data->ready_func (G_OBJECT (catalog), error, load_data->user_data);
+ g_object_unref (load_data->file);
g_free (load_data);
}
@@ -961,6 +966,7 @@ gth_catalog_load_from_file_async (GFile *file,
GFile *gio_file;
load_data = g_new0 (LoadData, 1);
+ load_data->file = g_object_ref (file);
load_data->ready_func = ready_func;
load_data->user_data = user_data;
diff --git a/extensions/catalogs/gth-file-source-catalogs.c b/extensions/catalogs/gth-file-source-catalogs.c
index 9107eebd..02dc2147 100644
--- a/extensions/catalogs/gth-file-source-catalogs.c
+++ b/extensions/catalogs/gth-file-source-catalogs.c
@@ -349,10 +349,8 @@ read_metadata_catalog_ready_cb (GObject *object,
if (error != NULL)
g_clear_error (&error);
- if (object != NULL) {
- gth_catalog_update_metadata (GTH_CATALOG (object), read_metadata->file_data);
- g_object_unref (object);
- }
+ gth_catalog_update_metadata (GTH_CATALOG (object), read_metadata->file_data);
+ g_object_unref (object);
read_metadata->callback (G_OBJECT (read_metadata->file_source), error, read_metadata->data);
read_metadata_free (read_metadata);
@@ -820,7 +818,7 @@ catalog_ready_cb (GObject *catalog,
gsize size;
GFile *gio_file;
- if ((error != NULL) || (catalog == NULL)) {
+ if (error != NULL) {
cod->ready_callback (G_OBJECT (cod->file_source), error, cod->user_data);
copy_op_data_free (cod);
return;
@@ -1235,7 +1233,7 @@ reorder_catalog_ready_cb (GObject *object,
gsize size;
GFile *gio_file;
- if ((error != NULL) || (object == NULL)) {
+ if (error != NULL) {
reorder_data->callback (G_OBJECT (reorder_data->file_source), error, reorder_data->data);
reorder_data_free (reorder_data);
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]