diff --git a/src/common/tags.c b/src/common/tags.c index c7bc409bc168..3a2a997dd47f 100644 --- a/src/common/tags.c +++ b/src/common/tags.c @@ -644,7 +644,8 @@ gboolean dt_tag_detach_by_string(const char *name, "SELECT tagid" " FROM main.tagged_images as ti, data.tags as t" " WHERE ti.tagid = t.id" - " AND t.name GLOB ?1", + " AND t.name GLOB ?1" + " AND ti.imgid = ?2", -1, &stmt, NULL); @@ -661,6 +662,7 @@ gboolean dt_tag_detach_by_string(const char *name, } DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 1, n, -1, SQLITE_TRANSIENT); + DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, imgid); gboolean res = FALSE; @@ -671,6 +673,8 @@ gboolean dt_tag_detach_by_string(const char *name, dt_tag_detach(tagid, imgid, undo_on, group_on); } + sqlite3_finalize(stmt); + g_free(n); return res;