Credit SGE - add missing output_track and additional precautions
authorGood Guy <good1.2guy@gmail.com>
Tue, 11 Mar 2025 21:00:31 +0000 (15:00 -0600)
committerGood Guy <good1.2guy@gmail.com>
Tue, 11 Mar 2025 21:00:31 +0000 (15:00 -0600)
cinelerra-5.1/plugins/blendalgebra/blendalgebra.C
cinelerra-5.1/plugins/blendalgebra/blendalgebra.h
cinelerra-5.1/plugins/blendprogram/blendprogram.C
cinelerra-5.1/plugins/blendprogram/blendprogram.h

index e1c8220007dd0cc8f4d997430caa79b6c2907daa..27abab3decf9b18b621143950fdad0f46fca3f98 100644 (file)
@@ -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()
index 78b90546b8d8b19edd1fc59b1a15fe364a6abe37..db3f96b7c096482830da01a9e4a6056d81c34f58 100644 (file)
@@ -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
index 70f27bc3836a3807ab808d2b8f3d82a337c300f0..3b5be0d145408f382ae6da9da2b366c3103220a2 100644 (file)
@@ -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()
index 126465825d38545d70fb7ef1da51faaa4a3d08fc..71d3614988f46c78d820195db0c2bf4f7bf66483 100644 (file)
@@ -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