From 295db3f966634ea214a7db0d6fece5e5e463b7c4 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Tue, 11 Mar 2025 15:00:31 -0600 Subject: [PATCH] Credit SGE - add missing output_track and additional precautions --- .../plugins/blendalgebra/blendalgebra.C | 76 +++++++++++-------- .../plugins/blendalgebra/blendalgebra.h | 2 + .../plugins/blendprogram/blendprogram.C | 35 ++++++--- .../plugins/blendprogram/blendprogram.h | 2 + 4 files changed, 72 insertions(+), 43 deletions(-) diff --git a/cinelerra-5.1/plugins/blendalgebra/blendalgebra.C b/cinelerra-5.1/plugins/blendalgebra/blendalgebra.C index e1c82200..27abab3d 100644 --- a/cinelerra-5.1/plugins/blendalgebra/blendalgebra.C +++ b/cinelerra-5.1/plugins/blendalgebra/blendalgebra.C @@ -81,11 +81,12 @@ int BlendAlgebraConfig::equivalent(BlendAlgebraConfig &that) { return !strcmp (funcname, that.funcname) && - parallel == that.parallel && - clipcolors == that.clipcolors && - clear_input == that.clear_input && - direction == that.direction && - colorspace == that.colorspace && + parallel == that.parallel && + clipcolors == that.clipcolors && + clear_input == that.clear_input && + direction == that.direction && + output_track == that.output_track && + colorspace == that.colorspace && EQUIV (red, that.red) && EQUIV (green, that.green) && EQUIV (blue, that.blue) && @@ -95,15 +96,16 @@ int BlendAlgebraConfig::equivalent(BlendAlgebraConfig &that) void BlendAlgebraConfig::copy_from(BlendAlgebraConfig &that) { strcpy (funcname, that.funcname); - parallel = that.parallel; - clipcolors = that.clipcolors; - clear_input = that.clear_input; - direction = that.direction; - colorspace = that.colorspace; - red = that.red; - green = that.green; - blue = that.blue; - alpha = that.alpha; + parallel = that.parallel; + clipcolors = that.clipcolors; + clear_input = that.clear_input; + direction = that.direction; + output_track = that.output_track; + colorspace = that.colorspace; + red = that.red; + green = that.green; + blue = that.blue; + alpha = that.alpha; } void BlendAlgebraConfig::interpolate (BlendAlgebraConfig &prev, @@ -123,11 +125,12 @@ void BlendAlgebraConfig::interpolate (BlendAlgebraConfig &prev, alpha = prev.alpha * prev_scale + next.alpha * next_scale; strcpy (funcname, prev.funcname); - parallel = prev.parallel; - clipcolors = prev.clipcolors; - clear_input = prev.clear_input; - direction = prev.direction; - colorspace = prev.colorspace; + parallel = prev.parallel; + clipcolors = prev.clipcolors; + clear_input = prev.clear_input; + direction = prev.direction; + output_track = prev.output_track; + colorspace = prev.colorspace; } const char *BlendAlgebraConfig::direction_to_text(int direction) @@ -464,14 +467,19 @@ void BlendAlgebraFileButton::run() file_box->update_filter ("*.ba"); file_box->unlock_window(); result = file_box->run_window(); + if (gui->quit_now) // plugin dialog closed, imitate Cancel + { + delete file_box; + file_box = 0; + return; + } if (file_box->reinit_path) // if set, a button was clicked { - fpath = file_box->get_current_path(); // current, as set by buttons #ifdef DEBUG - printf ("BlendAlgebraFileButton::run file_box returned %d reinit_path=%d\n fpath=%s\n", - result, file_box->reinit_path, fpath); + printf ("BlendAlgebraFileButton::run file_box returned %d reinit_path=%d\n changed_path=%s\n", + result, file_box->reinit_path, file_box->changed_path); #endif - strncpy (fname, fpath ? fpath : "", sizeof(fname)-1); + strcpy (fname, file_box->changed_path); // this path was set by buttons delete file_box; file_box = 0; continue; // reinit_path will be cleared on repeat in FileBox constructor @@ -553,7 +561,8 @@ BlendAlgebraFileBox::BlendAlgebraFileBox(BlendAlgebra *plugin, copy_curdir = 0; copy_usrlib = 0; file_edit = 0; - reinit_path = 0; + reinit_path = 0; // reinit_path and changed_path can be set by buttons + strcpy (changed_path, init_path); } BlendAlgebraFileBox::~BlendAlgebraFileBox() @@ -639,13 +648,12 @@ int BlendAlgebraToCurdir::handle_event() // Not exactly sure what operations on FileBox are really important file_box->fs->change_dir (dir); // force it to recognize the new dir - // This updates all paths, sets current_path and submitted_path of FileBox, - // but in memory only, text fields in the dialog are not actualized. + // Changed path is in memory only, dialog text fields are not actualized. // file_box->refresh() does not help to refresh text fields either. // Therefore we have to apply a trick with closing FileBox and // reopening it with the new generated path. Visited paths history // will be updated inside BlendAlgebraFileButton::run() in reinit_path loop. - file_box->update_paths (path); + strcpy (file_box->changed_path, path); file_box->reinit_path = 1; // set flag to reopen FileBox afterwards file_box->set_done(1); // temporarily close FileBox, will be reopened later @@ -704,7 +712,7 @@ int BlendAlgebraToUsrlib::handle_event() // Reinitialize FileBox with the modified path file_box->fs->change_dir (dir); - file_box->update_paths (path); + strcpy (file_box->changed_path, path); file_box->reinit_path = 1; // set flag to reopen FileBox afterwards file_box->set_done(1); // temporarily close FileBox, will be reopened later @@ -744,7 +752,7 @@ int BlendAlgebraToSyslib::handle_event() // Reinitialize FileBox with the modified path file_box->fs->change_dir (dir); - file_box->update_paths (path); + strcpy (file_box->changed_path, path); file_box->reinit_path = 1; // set flag to reopen FileBox afterwards file_box->set_done(1); // temporarily close FileBox, will be reopened later @@ -816,7 +824,7 @@ int BlendAlgebraCopyCurdir::handle_event() // Copying successful, now change dir to the location of the target file_box->fs->change_dir (dir); - file_box->update_paths (to_path); + strcpy (file_box->changed_path, to_path); file_box->reinit_path = 1; // set flag to reopen FileBox afterwards file_box->set_done(1); // temporarily close FileBox, will be reopened later @@ -1247,11 +1255,16 @@ BlendAlgebraWindow::BlendAlgebraWindow(BlendAlgebra *plugin) this->plugin = plugin; color_thread = 0; editing_lock = new Mutex("BlendAlgebraWindow::editing_lock"); - editing = 0; + editing = 0; + quit_now = 0; } BlendAlgebraWindow::~BlendAlgebraWindow() { + quit_now = 1; // cleanup in progress, stop mocking up with editing_lock + if (color_thread) color_thread->close_window(); + file_button->stop(); // force closing Attach... dialog + editing = 0; delete color_thread; delete editing_lock; } @@ -1378,6 +1391,7 @@ void BlendAlgebraWindow::update_key_sample() void BlendAlgebraWindow::done_event() { color_thread->close_window(); + file_button->stop(); } int BlendAlgebraWindow::close_event() diff --git a/cinelerra-5.1/plugins/blendalgebra/blendalgebra.h b/cinelerra-5.1/plugins/blendalgebra/blendalgebra.h index 78b90546..db3f96b7 100644 --- a/cinelerra-5.1/plugins/blendalgebra/blendalgebra.h +++ b/cinelerra-5.1/plugins/blendalgebra/blendalgebra.h @@ -199,6 +199,7 @@ public: BlendAlgebraFileEdit *file_edit; int reinit_path; + char changed_path[BCTEXTLEN]; }; class BlendAlgebraFileButton : public BC_GenericButton, public Thread @@ -362,6 +363,7 @@ public: Mutex *editing_lock; int editing; + int quit_now; }; // For multithreading processing engine diff --git a/cinelerra-5.1/plugins/blendprogram/blendprogram.C b/cinelerra-5.1/plugins/blendprogram/blendprogram.C index 70f27bc3..3b5be0d1 100644 --- a/cinelerra-5.1/plugins/blendprogram/blendprogram.C +++ b/cinelerra-5.1/plugins/blendprogram/blendprogram.C @@ -449,14 +449,19 @@ void BlendProgramFileButton::run() file_box->update_filter ("*.bp"); file_box->unlock_window(); result = file_box->run_window(); + if (gui->quit_now) // plugin dialog closed, imitate Cancel + { + delete file_box; + file_box = 0; + return; + } if (file_box->reinit_path) // if set, a button was clicked { - fpath = file_box->get_current_path(); // current, as set by buttons #ifdef DEBUG - printf ("BlendProgramFileButton::run file_box returned %d reinit_path=%d\n fpath=%s\n", - result, file_box->reinit_path, fpath); + printf ("BlendProgramFileButton::run file_box returned %d reinit_path=%d\n changed_path=%s\n", + result, file_box->reinit_path, file_box->changed_path); #endif - strncpy (fname, fpath ? fpath : "", sizeof(fname)-1); + strcpy (fname, file_box->changed_path); // this path was set by buttons delete file_box; file_box = 0; continue; // reinit_path will be cleared on repeat in FileBox constructor @@ -538,7 +543,8 @@ BlendProgramFileBox::BlendProgramFileBox(BlendProgram *plugin, copy_curdir = 0; copy_usrlib = 0; file_edit = 0; - reinit_path = 0; + reinit_path = 0; // reinit_path and changed_path can be set by buttons + strcpy (changed_path, init_path); } BlendProgramFileBox::~BlendProgramFileBox() @@ -624,13 +630,12 @@ int BlendProgramToCurdir::handle_event() // Not exactly sure what operations on FileBox are really important file_box->fs->change_dir (dir); // force it to recognize the new dir - // This updates all paths, sets current_path and submitted_path of FileBox, - // but in memory only, text fields in the dialog are not actualized. + // Changed path is in memory only, dialog text fields are not actualized. // file_box->refresh() does not help to refresh text fields either. // Therefore we have to apply a trick with closing FileBox and // reopening it with the new generated path. Visited paths history // will be updated inside BlendProgramFileButton::run() in reinit_path loop. - file_box->update_paths (path); + strcpy (file_box->changed_path, path); file_box->reinit_path = 1; // set flag to reopen FileBox afterwards file_box->set_done(1); // temporarily close FileBox, will be reopened later @@ -689,7 +694,7 @@ int BlendProgramToUsrlib::handle_event() // Reinitialize FileBox with the modified path file_box->fs->change_dir (dir); - file_box->update_paths (path); + strcpy (file_box->changed_path, path); file_box->reinit_path = 1; // set flag to reopen FileBox afterwards file_box->set_done(1); // temporarily close FileBox, will be reopened later @@ -729,7 +734,7 @@ int BlendProgramToSyslib::handle_event() // Reinitialize FileBox with the modified path file_box->fs->change_dir (dir); - file_box->update_paths (path); + strcpy (file_box->changed_path, path); file_box->reinit_path = 1; // set flag to reopen FileBox afterwards file_box->set_done(1); // temporarily close FileBox, will be reopened later @@ -801,7 +806,7 @@ int BlendProgramCopyCurdir::handle_event() // Copying successful, now change dir to the location of the target file_box->fs->change_dir (dir); - file_box->update_paths (to_path); + strcpy (file_box->changed_path, to_path); file_box->reinit_path = 1; // set flag to reopen FileBox afterwards file_box->set_done(1); // temporarily close FileBox, will be reopened later @@ -1186,11 +1191,16 @@ BlendProgramWindow::BlendProgramWindow(BlendProgram *plugin) this->plugin = plugin; color_thread = 0; editing_lock = new Mutex("BlendProgramWindow::editing_lock"); - editing = 0; + editing = 0; + quit_now = 0; } BlendProgramWindow::~BlendProgramWindow() { + quit_now = 1; // cleanup in progress, stop mocking up with editing_lock + if (color_thread) color_thread->close_window(); + file_button->stop(); // force closing Attach... dialog + editing = 0; delete color_thread; delete editing_lock; } @@ -1304,6 +1314,7 @@ void BlendProgramWindow::update_key_sample() void BlendProgramWindow::done_event() { color_thread->close_window(); + file_button->stop(); } int BlendProgramWindow::close_event() diff --git a/cinelerra-5.1/plugins/blendprogram/blendprogram.h b/cinelerra-5.1/plugins/blendprogram/blendprogram.h index 12646582..71d36149 100644 --- a/cinelerra-5.1/plugins/blendprogram/blendprogram.h +++ b/cinelerra-5.1/plugins/blendprogram/blendprogram.h @@ -190,6 +190,7 @@ public: BlendProgramFileEdit *file_edit; int reinit_path; + char changed_path[BCTEXTLEN]; }; class BlendProgramFileButton : public BC_GenericButton, public Thread @@ -332,6 +333,7 @@ public: Mutex *editing_lock; int editing; + int quit_now; }; // For multithreading processing engine -- 2.26.2