From 0e0c006d5ad3dd9b29b0fa12ed3edaf827752836 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Sat, 10 Apr 2021 19:46:50 +0200 Subject: [PATCH] fixed: thread locking problem in Image: method Lock() was used instead of Winix::Lock object --- winixd/core/image.cpp | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/winixd/core/image.cpp b/winixd/core/image.cpp index b7813ea..786b1a1 100644 --- a/winixd/core/image.cpp +++ b/winixd/core/image.cpp @@ -267,7 +267,7 @@ bool end; do { - class Lock lock_object(synchro); + Winix::Lock lock_object(synchro); if( i != image_tab.end() ) { @@ -412,18 +412,13 @@ void Image::CreateTmpFileName() // second thread (objects are not locked) bool Image::CreateCommand() { - class Lock lock_object(synchro); + Winix::Lock lock_object(synchro); // iq.SetAll(true, false); // iq.WhereId(item_work.file_id); morm::Finder finder(model_connector); - - { - // IMPROVEME we need a seperate model_connector for this thread - Lock(); - file_work = finder.select().where().eq(L"id", item_work.file_id).get(); - } + file_work = finder.select().where().eq(L"id", item_work.file_id).get(); // the file could have been changed especially when there is a long queue of files if( !file_work.found() ) @@ -495,13 +490,9 @@ void Image::ImageSavedCorrectly() { file_work.item_content.file_has_thumb = true; - { - // IMPROVEME we need a separate model_connector for this thread - Lock(); - file_work.propagate_connector(); - file_work.item_content.update(false); - //db->EditHasThumbById(true, file_work.id); - } + file_work.propagate_connector(); + file_work.item_content.update(false); + //db->EditHasThumbById(true, file_work.id); } log << log3 << "Image: generated a thumbnail: " << dst_path << logend; @@ -540,19 +531,15 @@ void Image::ImageSavedCorrectly() // second thread (objects are not locked) void Image::SaveImage() { - class Lock lock_object(synchro); + Winix::Lock lock_object(synchro); // the file could have been changed especially when creating the image lasted too long //iq.SetAll(true, false); //iq.WhereId(item_work.file_id); morm::Finder finder(model_connector); + file_work = finder.select().where().eq(L"id", item_work.file_id).get(); - { - // IMPROVEME we need a seperate model_connector for this thread - Lock(); - file_work = finder.select().where().eq(L"id", item_work.file_id).get(); - } // the file could have been changed especially when there is a long queue of files if( !file_work.found() ) @@ -603,7 +590,6 @@ void Image::CreateImage() } else { - class Lock lock_object(synchro); log << log3 << "Image: some problems with creating an image" << ", 'convert' process returned: " << res << logend; }