[gnome-photos/sam/tracker2-domain: 1/3] Fix Tracker-related assert fails
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/sam/tracker2-domain: 1/3] Fix Tracker-related assert fails
- Date: Tue, 1 Sep 2020 11:48:42 +0000 (UTC)
commit 141c09d4630c2c8bac21e6826bef1e0c8c3ab9f5
Author: Sam Thursfield <sam afuera me uk>
Date: Tue Sep 1 13:20:48 2020 +0200
Fix Tracker-related assert fails
Fixes warnings like this:
(org.gnome.Photos:16): Tracker-CRITICAL **: 13:04:34.406: tracker_sparql_cursor_real_get_integer:
assertion 'tracker_sparql_cursor_get_value_type (self, column) == TRACKER_SPARQL_VALUE_TYPE_INTEGER' failed
In one case, the issue was that the nfo:fileLastModified and
nie:contentLastModified properties have type xsd:dateTime, which
Tracker returns as ISO8601 date string and not an integer or boolean.
In the other case, if the extractor has not yet run for a photo then
various variables in the query will be unbound, we need to check for
this situation and use a default value.
src/photos-base-item.c | 30 ++++++++++++++++++++++++------
src/photos-item-manager.c | 10 ++++++++--
2 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 143431f9..28df4c2d 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -2756,6 +2756,24 @@ photos_base_item_update_info_from_type (PhotosBaseItem *self)
}
+static gint64
+photos_cursor_get_integer_with_default (TrackerSparqlCursor *cursor, PhotosQueryColumns column, gint64
default_value)
+{
+ if (tracker_sparql_cursor_get_value_type (cursor, column) == TRACKER_SPARQL_VALUE_TYPE_UNBOUND)
+ return default_value;
+ return tracker_sparql_cursor_get_integer (cursor, column);
+}
+
+
+static double
+photos_cursor_get_double_with_default (TrackerSparqlCursor *cursor, PhotosQueryColumns column, double
default_value)
+{
+ if (tracker_sparql_cursor_get_value_type (cursor, column) == TRACKER_SPARQL_VALUE_TYPE_UNBOUND)
+ return default_value;
+ return tracker_sparql_cursor_get_double (cursor, column);
+}
+
+
static void
photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor *cursor)
{
@@ -2875,8 +2893,8 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
priv->orientation = PHOTOS_ORIENTATION_TOP;
}
- height = tracker_sparql_cursor_get_integer (cursor, PHOTOS_QUERY_COLUMNS_HEIGHT);
- width = tracker_sparql_cursor_get_integer (cursor, PHOTOS_QUERY_COLUMNS_WIDTH);
+ height = photos_cursor_get_integer_with_default (cursor, PHOTOS_QUERY_COLUMNS_HEIGHT, 0);
+ width = photos_cursor_get_integer_with_default (cursor, PHOTOS_QUERY_COLUMNS_WIDTH, 0);
if (priv->orientation == PHOTOS_ORIENTATION_BOTTOM
|| priv->orientation == PHOTOS_ORIENTATION_BOTTOM_MIRROR
|| priv->orientation == PHOTOS_ORIENTATION_TOP
@@ -2891,10 +2909,10 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
priv->width = height;
}
- priv->exposure_time = tracker_sparql_cursor_get_double (cursor, PHOTOS_QUERY_COLUMNS_EXPOSURE_TIME);
- priv->fnumber = tracker_sparql_cursor_get_double (cursor, PHOTOS_QUERY_COLUMNS_FNUMBER);
- priv->focal_length = tracker_sparql_cursor_get_double (cursor, PHOTOS_QUERY_COLUMNS_FOCAL_LENGTH);
- priv->iso_speed = tracker_sparql_cursor_get_double (cursor, PHOTOS_QUERY_COLUMNS_ISO_SPEED);
+ priv->exposure_time = photos_cursor_get_double_with_default (cursor, PHOTOS_QUERY_COLUMNS_EXPOSURE_TIME,
0.0);
+ priv->fnumber = photos_cursor_get_double_with_default (cursor, PHOTOS_QUERY_COLUMNS_FNUMBER, 0.0);
+ priv->focal_length = photos_cursor_get_double_with_default (cursor, PHOTOS_QUERY_COLUMNS_FOCAL_LENGTH,
0.0);
+ priv->iso_speed = photos_cursor_get_double_with_default (cursor, PHOTOS_QUERY_COLUMNS_ISO_SPEED, 0.0);
flash = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_FLASH, NULL);
priv->flash = g_quark_from_string (flash);
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index c44fbbfc..0a218137 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -179,9 +179,15 @@ photos_item_manager_can_add_cursor_for_mode (PhotosItemManager *self,
PhotosWindowMode mode)
{
gboolean ret_val = TRUE;
- gint64 mtime;
+ const gchar *mtime_str;
+ g_autoptr (GDateTime) mtime_datetime = NULL;
+ gint64 mtime = 0;
+
+ mtime_str = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_MTIME, NULL);
+ mtime_datetime = g_date_time_new_from_iso8601 (mtime_str, NULL);
+ if (mtime_datetime)
+ mtime = g_date_time_to_unix (mtime_datetime);
- mtime = tracker_sparql_cursor_get_boolean (cursor, PHOTOS_QUERY_COLUMNS_MTIME);
ret_val = photos_item_manager_can_add_mtime_for_mode (self, mtime, mode);
return ret_val;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]