Skip to content

Commit

Permalink
Merge pull request #1384 from GHswitt/master
Browse files Browse the repository at this point in the history
Sync XMPs after tag attach/detach via Lua API.
  • Loading branch information
boucman committed Jan 8, 2017
2 parents d6522a0 + 4a9127e commit 26b7112
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/lua/tags.c
Expand Up @@ -19,6 +19,7 @@
#include "common/darktable.h"
#include "common/debug.h"
#include "common/tags.h"
#include "common/image.h"
#include "lua/image.h"
#include "lua/types.h"

Expand Down Expand Up @@ -147,7 +148,30 @@ static int tag_delete(lua_State *L)
{
dt_lua_tag_t tagid;
luaA_to(L, dt_lua_tag_t, &tagid, -1);
dt_tag_remove(tagid, true);

GList *tagged_images = NULL;
sqlite3_stmt *stmt;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "SELECT imgid FROM main.tagged_images WHERE tagid=?1",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, tagid);
while(sqlite3_step(stmt) == SQLITE_ROW)
{
tagged_images = g_list_append(tagged_images, GINT_TO_POINTER(sqlite3_column_int(stmt, 0)));
}
sqlite3_finalize(stmt);

dt_tag_remove(tagid, TRUE);

GList *list_iter;
if((list_iter = g_list_first(tagged_images)) != NULL)
{
do
{
dt_image_synch_xmp(GPOINTER_TO_INT(list_iter->data));
} while((list_iter = g_list_next(list_iter)) != NULL);
}
g_list_free(g_list_first(tagged_images));

return 0;
}

Expand All @@ -167,6 +191,7 @@ int dt_lua_tag_attach(lua_State *L)
luaA_to(L, dt_lua_image_t, &imgid, 2);
}
dt_tag_attach(tagid, imgid);
dt_image_synch_xmp(imgid);
return 0;
}

Expand All @@ -185,6 +210,7 @@ int dt_lua_tag_detach(lua_State *L)
luaA_to(L, dt_lua_image_t, &imgid, 2);
}
dt_tag_detach(tagid, imgid);
dt_image_synch_xmp(imgid);
return 0;
}

Expand Down

0 comments on commit 26b7112

Please sign in to comment.