asset drag/drop to viewers, bluebanana bug, listbox fontlist highlight
[goodguy/history.git] / cinelerra-5.1 / cinelerra / batchrender.C
index d2a7341f0ff86a7ddd0c6086b0e91700bcac1883..62ef2955b2a6b48ffb2acda58d5548e380cf7c4b 100644 (file)
@@ -31,6 +31,7 @@
 #include "edl.h"
 #include "edlsession.h"
 #include "errorbox.h"
+#include "file.h"
 #include "filesystem.h"
 #include "filexml.h"
 #include "keyframe.h"
@@ -139,12 +140,7 @@ void BatchRenderJob::load(FileXML *file)
                        BC_Hash defaults;
                        defaults.load_string(file->read_text());
                        asset->load_defaults(&defaults,
-                               "",
-                               0,
-                               1,
-                               0,
-                               0,
-                               0);
+                               "", 0, 1, 0, 0, 0);
                }
        }
 }
@@ -205,8 +201,9 @@ BatchRenderThread::BatchRenderThread(MWindow *mwindow)
        default_job = 0;
        boot_defaults = 0;
        preferences = 0;
+       warn = 1;
        render = 0;
-       file_entries = 0;
+       batch_path[0] = 0;
 }
 
 BatchRenderThread::BatchRenderThread()
@@ -219,8 +216,9 @@ BatchRenderThread::BatchRenderThread()
        default_job = 0;
        boot_defaults = 0;
        preferences = 0;
+       warn = 1;
        render = 0;
-       file_entries = 0;
+       batch_path[0] = 0;
 }
 
 BatchRenderThread::~BatchRenderThread()
@@ -229,28 +227,26 @@ BatchRenderThread::~BatchRenderThread()
        delete boot_defaults;
        delete preferences;
        delete render;
-       if( file_entries ) {
-               file_entries->remove_all_objects();
-               delete file_entries;
+}
+
+void BatchRenderThread::reset(const char *path)
+{
+       if( path ) {
+               strcpy(batch_path, path);
+               warn = 1;
        }
+       current_job = 0;
+       rendering_job = -1;
+       delete default_job;  default_job = 0;
+       jobs.remove_all_objects();
 }
 
 void BatchRenderThread::handle_close_event(int result)
 {
 // Save settings
-       char path[BCTEXTLEN];
-       path[0] = 0;
-       save_jobs(path);
+       save_jobs(batch_path);
        save_defaults(mwindow->defaults);
-       delete default_job;
-       default_job = 0;
-       jobs.remove_all_objects();
-       if(file_entries)
-       {
-               file_entries->remove_all_objects();
-               delete file_entries;
-               file_entries = 0;
-       }
+       reset();
 }
 
 BC_Window* BatchRenderThread::new_gui()
@@ -258,26 +254,7 @@ BC_Window* BatchRenderThread::new_gui()
        current_start = 0.0;
        current_end = 0.0;
        default_job = new BatchRenderJob(mwindow->preferences);
-
-
-       if(!file_entries)
-       {
-               file_entries = new ArrayList<BC_ListBoxItem*>;
-               FileSystem fs;
-               char string[BCTEXTLEN];
-       // Load current directory
-               fs.update(getcwd(string, BCTEXTLEN));
-               for(int i = 0; i < fs.total_files(); i++)
-               {
-                       file_entries->append(
-                               new BC_ListBoxItem(
-                                       fs.get_entry(i)->get_name()));
-               }
-       }
-
-       char path[BCTEXTLEN];
-       path[0] = 0;
-       load_jobs(path, mwindow->preferences);
+       load_jobs(batch_path, mwindow->preferences);
        load_defaults(mwindow->defaults);
        this->gui = new BatchRenderGUI(mwindow,
                this,
@@ -296,16 +273,19 @@ void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
        int result = 0;
 
        jobs.remove_all_objects();
-       if(path[0])
-               file.read_from_file(path);
-       else
-               file.read_from_file(create_path(path));
+       if( !path ) path = batch_path;
+       if( !path[0] ) create_path(path);
+       file.read_from_file(path);
 
        while(!result)
        {
                if(!(result = file.read_tag()))
                {
-                       if(file.tag.title_is("JOB"))
+                       if(file.tag.title_is("JOBS"))
+                       {
+                               warn = file.tag.get_property("WARN", 1);
+                       }
+                       else if(file.tag.title_is("JOB"))
                        {
                                BatchRenderJob *job;
                                jobs.append(job = new BatchRenderJob(preferences));
@@ -318,17 +298,23 @@ void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
 void BatchRenderThread::save_jobs(char *path)
 {
        FileXML file;
+       file.tag.set_title("JOBS");
+       file.tag.set_property("WARN", warn);
+       file.append_tag();
+       file.append_newline();
 
        for(int i = 0; i < jobs.total; i++)
        {
                file.tag.set_title("JOB");
                jobs.values[i]->save(&file);
        }
+       file.tag.set_title("/JOBS");
+       file.append_tag();
+       file.append_newline();
 
-       if(path[0])
-               file.write_to_file(path);
-       else
-               file.write_to_file(create_path(path));
+       if( !path ) path = batch_path;
+       if( !path[0] ) create_path(path);
+       file.write_to_file(path);
 }
 
 void BatchRenderThread::load_defaults(BC_Hash *defaults)
@@ -336,12 +322,7 @@ void BatchRenderThread::load_defaults(BC_Hash *defaults)
        if(default_job)
        {
                default_job->asset->load_defaults(defaults,
-                       "BATCHRENDER_",
-                       1,
-                       1,
-                       1,
-                       1,
-                       1);
+                       "BATCHRENDER_", 1, 1, 1, 1, 1);
                default_job->fix_strategy();
        }
 
@@ -358,12 +339,7 @@ void BatchRenderThread::save_defaults(BC_Hash *defaults)
        if(default_job)
        {
                default_job->asset->save_defaults(defaults,
-                       "BATCHRENDER_",
-                       1,
-                       1,
-                       1,
-                       1,
-                       1);
+                       "BATCHRENDER_", 1, 1, 1, 1, 1);
                defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
        }
        for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
@@ -382,7 +358,7 @@ void BatchRenderThread::save_defaults(BC_Hash *defaults)
 char* BatchRenderThread::create_path(char *string)
 {
        FileSystem fs;
-       sprintf(string, "%s", BCASTDIR);
+       sprintf(string, "%s/", File::get_config_path());
        fs.complete_path(string);
        strcat(string, BATCH_PATH);
        return string;
@@ -464,43 +440,71 @@ char* BatchRenderThread::get_current_edl()
 // Test EDL files for existence
 int BatchRenderThread::test_edl_files()
 {
-       for(int i = 0; i < jobs.total; i++)
-       {
-               if(jobs.values[i]->enabled)
-               {
-                       const char *path = jobs.values[i]->edl_path;
-                       if( *path == '@' ) ++path;
-                       FILE *fd = fopen(path, "r");
-                       if(!fd)
-                       {
-                               char string[BCTEXTLEN];
-                               sprintf(string, _("EDL %s not found.\n"), jobs.values[i]->edl_path);
-                               if(mwindow)
-                               {
-                                       ErrorBox error_box(_(PROGRAM_NAME ": Error"),
-                                               mwindow->gui->get_abs_cursor_x(1),
-                                               mwindow->gui->get_abs_cursor_y(1));
-                                       error_box.create_objects(string);
-                                       error_box.run_window();
-                                       gui->button_enable();
+       int not_equiv = 0, ret = 0;
+       const char *path = 0;
+
+       for( int i=0; !ret && i<jobs.size(); ++i ) {
+               if( !jobs.values[i]->enabled ) continue;
+               const char *path = jobs.values[i]->edl_path;
+               int is_script = *path == '@' ? 1 : 0;
+               if( is_script ) ++path;
+               FILE *fp = fopen(path, "r");
+               if( fp ) {
+                       if( warn && mwindow && !is_script ) {
+                               fseek(fp, 0, SEEK_END);
+                               int64_t sz = ftell(fp);
+                               fseek(fp, 0, SEEK_SET);
+                               char *bfr = new char[sz+1];
+                               int64_t len = fread(bfr, 1, sz+1, fp);
+                               if( len == sz ) {
+                                       FileXML file;  file.set_shared_input(bfr, len);
+                                       EDL *edl = new EDL; edl->create_objects();
+                                       edl->load_xml(&file, LOAD_ALL);
+                                       double pos = edl->equivalent_output(mwindow->edl);
+                                       if( pos >= 0 ) ++not_equiv;
+                                       edl->remove_user();
                                }
                                else
-                               {
-                                       fprintf(stderr,
-                                               "%s",
-                                               string);
-                               }
-
-                               is_rendering = 0;
-                               return 1;
-                       }
-                       else
-                       {
-                               fclose(fd);
+                                       ret = 1;
+                               delete [] bfr;
                        }
+                       fclose(fp);
                }
+               else
+                       ret = 1;
        }
-       return 0;
+
+       if( ret ) {
+               char string[BCTEXTLEN];
+               sprintf(string, _("EDL %s not found.\n"), path);
+               if( mwindow ) {
+                       ErrorBox error_box(_(PROGRAM_NAME ": Error"),
+                               mwindow->gui->get_abs_cursor_x(1),
+                               mwindow->gui->get_abs_cursor_y(1));
+                       error_box.create_objects(string);
+                       error_box.run_window();
+                       gui->button_enable();
+               }
+               else {
+                       fprintf(stderr, "%s", string);
+               }
+               is_rendering = 0;
+       }
+       else if( warn && mwindow && not_equiv > 0 ) {
+               fprintf(stderr, _("%d job EDLs do not match session edl\n"), not_equiv);
+               char string[BCTEXTLEN], *sp = string;
+               sp += sprintf(sp, _("%d job EDLs do not match session edl\n"),not_equiv);
+               sp += sprintf(sp, _("press cancel to abandon batch render"));
+               mwindow->show_warning(&warn, string);
+               if( mwindow->wait_warning() ) {
+                       gui->button_enable();
+                       is_rendering = 0;
+                       ret = 1;
+               }
+               gui->warning->update(warn);
+       }
+
+       return ret;
 }
 
 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
@@ -558,11 +562,21 @@ void BatchRenderThread::start_rendering(char *config_path,
        // XXX the above stuff is leaked,
 //PRINT_TRACE
 // Initialize stuff which MWindow does.
-       signals->initialize();
+       signals->initialize("/tmp/cinelerra_batch%d.dmp");
        MWindow::init_defaults(boot_defaults, config_path);
        load_defaults(boot_defaults);
        preferences = new Preferences;
        preferences->load_defaults(boot_defaults);
+       BC_Signals::set_trap_hook(trap_hook, this);
+       BC_Signals::set_catch_segv(preferences->trap_sigsegv);
+       BC_Signals::set_catch_intr(0);
+       if( preferences->trap_sigsegv ) {
+               BC_Trace::enable_locks();
+       }
+       else {
+               BC_Trace::disable_locks();
+       }
+
        MWindow::init_plugins(0, preferences);
        char font_path[BCTEXTLEN];
        strcpy(font_path, preferences->plugin_dir);
@@ -571,6 +585,7 @@ void BatchRenderThread::start_rendering(char *config_path,
        BC_WindowBase::get_resources()->vframe_shm = 1;
 
 //PRINT_TRACE
+       strcpy(this->batch_path, batch_path);
        load_jobs(batch_path, preferences);
        save_jobs(batch_path);
        save_defaults(boot_defaults);
@@ -604,11 +619,9 @@ void BatchRenderThread::start_rendering(char *config_path,
 void BatchRenderThread::start_rendering()
 {
        if(is_rendering) return;
-
        is_rendering = 1;
-       char path[BCTEXTLEN];
-       path[0] = 0;
-       save_jobs(path);
+
+       save_jobs(batch_path);
        save_defaults(mwindow->defaults);
        gui->button_disable();
 
@@ -694,28 +707,25 @@ void BatchRenderThread::move_batch(int src, int dst)
        }
 }
 
-
+void BatchRenderThread::trap_hook(FILE *fp, void *vp)
+{
+       MWindow *mwindow = ((BatchRenderThread *)vp)->mwindow;
+       fprintf(fp, "\nEDL:\n");
+       mwindow->dump_edl(fp);
+       fprintf(fp, "\nUNDO:\n");
+       mwindow->dump_undo(fp);
+       fprintf(fp, "\nEXE:\n");
+       mwindow->dump_exe(fp);
+}
 
 
 
 
 
 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow,
-       BatchRenderThread *thread,
-       int x,
-       int y,
-       int w,
-       int h)
+       BatchRenderThread *thread, int x, int y, int w, int h)
  : BC_Window(_(PROGRAM_NAME ": Batch Render"),
-       x,
-       y,
-       w,
-       h,
-       50,
-       50,
-       1,
-       0,
-       1)
+       x, y, w, h, 730, 400, 1, 0, 1)
 {
        this->mwindow = mwindow;
        this->thread = thread;
@@ -737,108 +747,65 @@ void BatchRenderGUI::create_objects()
 
        int x = mwindow->theme->batchrender_x1;
        int y = 5;
-       int x1 = mwindow->theme->batchrender_x1;
-       int x2 = mwindow->theme->batchrender_x2;
-       //int x3 = mwindow->theme->batchrender_x3;
-       int y1 = y;
-       int y2;
+       int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
+       int y1 = 5, y2 = 5;
 
 // output file
-       add_subwindow(output_path_title = new BC_Title(x1, y, _("Output path:")));
-       y += 20;
-       format_tools = new BatchFormat(mwindow,
-                                       this,
-                                       thread->get_current_asset());
+       add_subwindow(output_path_title = new BC_Title(x1, y1, _("Output path:")));
+       y1 += output_path_title->get_h() + mwindow->theme->widget_border;
+
+       format_tools = new BatchFormat(mwindow, this, thread->get_current_asset());
        format_tools->set_w(get_w() / 2);
-       format_tools->create_objects(x,
-                                               y,
-                                               1,
-                                               1,
-                                               1,
-                                               1,
-                                               0,
-                                               1,
-                                               0,
-                                               0,
-                                               &thread->get_current_job()->strategy,
-                                               0);
-
-       x2 = x;
-       y2 = y + 10;
-       x += format_tools->get_w();
-       y = y1;
-       x1 = x;
-       //x3 = x + 80;
+       format_tools->create_objects(x1, y1, 1, 1, 1, 1, 0, 1, 0, 0,
+                       &thread->get_current_job()->strategy, 0);
 
 // input EDL
-       x = x1;
-       add_subwindow(edl_path_title = new BC_Title(x, y, _("EDL Path:")));
-       y += 20;
-       add_subwindow(edl_path_text = new BatchRenderEDLPath(
-               thread,
-               x,
-               y,
-               get_w() - x - 40,
-               thread->get_current_edl()));
+       add_subwindow(edl_path_title = new BC_Title(x2, y2, _("EDL Path:")));
+       y2 += edl_path_title->get_h() + mwindow->theme->widget_border;
 
-       x += edl_path_text->get_w();
+       x = x2;  y = y2;
+       add_subwindow(edl_path_text = new BatchRenderEDLPath( thread,
+               x, y, get_w()-x - 40, thread->get_current_edl()));
+       x =  x2 + edl_path_text->get_w();
        add_subwindow(edl_path_browse = new BrowseButton(
-               mwindow, this, edl_path_text, x, y, thread->get_current_edl(),
+               mwindow->theme, this, edl_path_text, x, y, thread->get_current_edl(),
                _("Input EDL"), _("Select an EDL to load:"), 0));
+       y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
 
-       x = x1;
-       y += 64;
-       update_selected_edl = new BatchRenderUpdateEDL(thread, x, y);
-       add_subwindow(update_selected_edl);
+       x = x2;  y = y2;
+       add_subwindow(update_selected_edl = new BatchRenderUpdateEDL(thread, x, y));
        y += update_selected_edl->get_h() + mwindow->theme->widget_border;
-
-       add_subwindow(new_batch = new BatchRenderNew(thread,
-               x,
-               y));
-       x += new_batch->get_w() + 10;
-
-       add_subwindow(delete_batch = new BatchRenderDelete(thread,
-               x,
-               y));
-       x = new_batch->get_x();
-       y += new_batch->get_h() + mwindow->theme->widget_border;
-       use_current_edl = new BatchRenderCurrentEDL(thread, x, y);
-       add_subwindow(use_current_edl);
+       add_subwindow(use_current_edl = new BatchRenderCurrentEDL(thread, x, y));
+       y += use_current_edl->get_h() + mwindow->theme->widget_border;
        if( !mwindow->edl || !mwindow->edl->path[0] ) use_current_edl->disable();
+       add_subwindow(new_batch = new BatchRenderNew(thread, x, y));
+       x += new_batch->get_w() + mwindow->theme->widget_border;
+       add_subwindow(delete_batch = new BatchRenderDelete(thread, x, y));
+       x = x2;  y += delete_batch->get_h() + mwindow->theme->widget_border;
+       add_subwindow(savelist_batch = new BatchRenderSaveList(thread, x, y));
+       x += savelist_batch->get_w() + mwindow->theme->widget_border;
+       add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, x, y));
+       y += loadlist_batch->get_h() + mwindow->theme->widget_border;
+       add_subwindow(warning = new BatchRenderWarning(thread, x2, y));
+       y2 = y + warning->get_h() + mwindow->theme->widget_border;
+       if( y2 > y1 ) y1 = y2;
+       x = mwindow->theme->batchrender_x1, y = y1;
 
-       savelist_batch = new BatchRenderSaveList(thread, x, y);
-       add_subwindow(savelist_batch);
-       x += savelist_batch->get_w() + 10;
-
-       loadlist_batch = new BatchRenderLoadList(thread, x, y);
-       add_subwindow(loadlist_batch);
-       x += loadlist_batch->get_w() + 10;
-
-       x = x2;
-       y = y2;
        add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
-       y += 20;
-       add_subwindow(batch_list = new BatchRenderList(thread,
-               x,
-               y,
-               get_w() - x - 10,
-               get_h() - y - BC_GenericButton::calculate_h() - 15));
-
-       y += batch_list->get_h() + 10;
-       add_subwindow(start_button = new BatchRenderStart(thread,
-           x,
-           y));
-       x = get_w() / 2 -
-               BC_GenericButton::calculate_w(this, _("Stop")) / 2;
-       add_subwindow(stop_button = new BatchRenderStop(thread,
-               x,
-               y));
-       x = get_w() -
-               BC_GenericButton::calculate_w(this, _("Close")) -
-               10;
-       add_subwindow(cancel_button = new BatchRenderCancel(thread,
-               x,
-               y));
+       x1 = x + list_title->get_w() + mwindow->theme->widget_border;;
+       add_subwindow(batch_path = new BC_Title(x1, y, thread->batch_path, MEDIUMFONT));
+       y += list_title->get_h() + mwindow->theme->widget_border;
+       y1 = get_h();
+       y1 -= 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
+       add_subwindow(batch_list = new BatchRenderList(thread, x, y,
+               get_w() - x - 10, y1 - y));
+       y += batch_list->get_h() + mwindow->theme->widget_border;
+
+       add_subwindow(start_button = new BatchRenderStart(thread, x, y));
+       x = get_w() / 2 - BC_GenericButton::calculate_w(this, _("Stop")) / 2;
+       add_subwindow(stop_button = new BatchRenderStop(thread, x, y));
+       x = get_w() - BC_GenericButton::calculate_w(this, _("Close")) - 10;
+       add_subwindow(cancel_button = new BatchRenderCancel(thread, x, y));
 
        show_window(1);
        unlock_window();
@@ -869,63 +836,53 @@ int BatchRenderGUI::resize_event(int w, int h)
 
        int x = mwindow->theme->batchrender_x1;
        int y = 5;
-       int x1 = mwindow->theme->batchrender_x1;
-       int x2 = mwindow->theme->batchrender_x2;
-       //int x3 = mwindow->theme->batchrender_x3;
-       int y1 = y;
-       int y2;
-
-       output_path_title->reposition_window(x1, y);
-       y += 20;
-       format_tools->reposition_window(x, y);
-       x2 = x;
-       y2 = y + 10;
-       y = y1;
-       x += format_tools->get_w();
-       x1 = x;
-       //x3 = x + 80;
-
-       x = x1;
+       int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
+       int y1 = 5, y2 = 5;
+
+// output file
+       output_path_title->reposition_window(x1, y1);
+       y1 += output_path_title->get_h() + mwindow->theme->widget_border;
+       format_tools->reposition_window(x1, y1);
+
+// input EDL
+       x = x2, y = y2;
        edl_path_title->reposition_window(x, y);
-       y += 20;
+       y += edl_path_title->get_h() + mwindow->theme->widget_border;
        edl_path_text->reposition_window(x, y, w - x - 40);
        x += edl_path_text->get_w();
        edl_path_browse->reposition_window(x, y);
+       y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
 
-       x = x1;
-//     y += 30;
-//     status_title->reposition_window(x, y);
-//     x = x3;
-//     status_text->reposition_window(x, y);
-//     x = x1;
-//     y += 30;
-//     progress_bar->reposition_window(x, y, w - x - 10);
-
-       y += 30;
+       x = x2;  y = y2;
        update_selected_edl->reposition_window(x, y);
        y += update_selected_edl->get_h() + mwindow->theme->widget_border;
+       use_current_edl->reposition_window(x, y);
+       y += use_current_edl->get_h() + mwindow->theme->widget_border;
        new_batch->reposition_window(x, y);
-       x += new_batch->get_w() + 10;
+       x += new_batch->get_w() + mwindow->theme->widget_border;
        delete_batch->reposition_window(x, y);
-       x = new_batch->get_x();
-       y += new_batch->get_h() + mwindow->theme->widget_border;
-       use_current_edl->reposition_window(x, y);
 
-       x = x2;
-       y = y2;
-       int y_margin = get_h() - batch_list->get_h();
+       x = x2;  y += delete_batch->get_h() + mwindow->theme->widget_border;
+       savelist_batch->reposition_window(x, y);
+       x += savelist_batch->get_w() + mwindow->theme->widget_border;
+       loadlist_batch->reposition_window(x, y);
+       y += loadlist_batch->get_h() + mwindow->theme->widget_border;
+       warning->reposition_window(x2, y);
+
+       y1 = 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
+       y2 = get_h() - y1 - batch_list->get_h();
+       y2 -= list_title->get_h() + mwindow->theme->widget_border;
+
+       x = mwindow->theme->batchrender_x1;  y = y2;
        list_title->reposition_window(x, y);
-       y += 20;
-       batch_list->reposition_window(x, y, w - x - 10, h - y_margin);
+       y += list_title->get_h() + mwindow->theme->widget_border;
+       batch_list->reposition_window(x, y, w - x - 10, h - y - y1);
+       y += batch_list->get_h() + mwindow->theme->widget_border;
 
-       y += batch_list->get_h() + 10;
        start_button->reposition_window(x, y);
-       x = w / 2 -
-               stop_button->get_w() / 2;
+       x = w / 2 - stop_button->get_w() / 2;
        stop_button->reposition_window(x, y);
-       x = w -
-               cancel_button->get_w() -
-               10;
+       x = w - cancel_button->get_w() - 10;
        cancel_button->reposition_window(x, y);
        return 1;
 }
@@ -1066,9 +1023,7 @@ BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
 
 int BatchRenderEDLPath::handle_event()
 {
-// Suggestions
-       calculate_suggestions(thread->file_entries);
-
+       calculate_suggestions();
        strcpy(thread->get_current_edl(), get_text());
        thread->gui->create_list(1);
        return 1;
@@ -1112,7 +1067,7 @@ int BatchRenderDelete::handle_event()
 BatchRenderSaveList::BatchRenderSaveList(BatchRenderThread *thread,
        int x,
        int y)
- : BC_GenericButton(x, y, _("Save List"))
+ : BC_GenericButton(x, y, _("Save Jobs"))
 {
        this->thread = thread;
        set_tooltip(_("Save a Batch Render List"));
@@ -1157,27 +1112,21 @@ void BatchRenderSaveList::run()
 {
        char default_path[BCTEXTLEN];
        sprintf(default_path, "~");
-       BC_FileBox filewindow(100,
-                             100,
-                             this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
-                             _("Save Batch Render List"),
-                             _("Enter a Batch Render filename to save as:"),
-                             0,
-                             0,
-                             0,
-                             0);
-
+       thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
+       BC_FileBox filewindow(100, 100, default_path, _("Save Batch Render List"),
+                       _("Enter a Batch Render filename to save as:"),
+                       0, 0, 0, 0);
        gui = &filewindow;
 
        startup_lock->unlock();
        filewindow.create_objects();
 
        int result2 = filewindow.run_window();
-
-       if(!result2)
-       {
-               this->thread->save_jobs(filewindow.get_submitted_path());
-               this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
+       if(!result2) {
+               strcpy(thread->batch_path, filewindow.get_submitted_path());
+               thread->gui->batch_path->update(thread->batch_path);
+               thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
+               thread->save_jobs(thread->batch_path);
        }
 
        this->thread->gui->flush();
@@ -1198,7 +1147,7 @@ int BatchRenderSaveList::keypress_event() {
 BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
        int x,
        int y)
-  : BC_GenericButton(x, y, _("Load List")),
+  : BC_GenericButton(x, y, _("Load Jobs")),
     Thread()
 {
        this->thread = thread;
@@ -1210,8 +1159,7 @@ BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
 BatchRenderLoadList::~BatchRenderLoadList()
 {
        startup_lock->lock("BatchRenderLoadList::~BrowseButton");
-       if(gui)
-       {
+       if(gui) {
                gui->lock_window();
                gui->set_done(1);
                gui->unlock_window();
@@ -1223,10 +1171,8 @@ BatchRenderLoadList::~BatchRenderLoadList()
 
 int BatchRenderLoadList::handle_event()
 {
-       if(Thread::running())
-       {
-               if(gui)
-               {
+       if(Thread::running()) {
+               if(gui) {
                        gui->lock_window();
                        gui->raise_window();
                        gui->unlock_window();
@@ -1244,31 +1190,27 @@ void BatchRenderLoadList::run()
 {
        char default_path[BCTEXTLEN];
        sprintf(default_path, "~");
-       BC_FileBox filewindow(100,
-                             100,
-                             this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
-                             _("Load Batch Render List"),
-                             _("Enter a Batch Render filename to load from:"),
-                             0,
-                             0,
-                             0,
-                             0);
-
+       thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
+       BC_FileBox filewindow(100, 100, default_path, _("Load Batch Render List"),
+                       _("Enter a Batch Render filename to load from:"),
+                       0, 0, 0, 0);
        gui = &filewindow;
 
        startup_lock->unlock();
        filewindow.create_objects();
 
        int result2 = filewindow.run_window();
-
-       if(!result2)
-       {
-               this->thread->load_jobs(filewindow.get_submitted_path(),this->thread->mwindow->preferences);
-               this->thread->gui->create_list(1);
-               this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
+       if(!result2) {
+               strcpy(thread->batch_path, filewindow.get_submitted_path());
+               thread->gui->batch_path->update(thread->batch_path);
+               thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
+               thread->load_jobs(thread->batch_path, thread->mwindow->preferences);
+               thread->gui->create_list(1);
+               thread->current_job = 0;
+               thread->gui->change_job();
        }
 
-       this->thread->gui->flush();
+       thread->gui->flush();
        startup_lock->lock("BatchRenderLoadList::run");
        gui = 0;
        startup_lock->unlock();
@@ -1445,6 +1387,19 @@ int BatchRenderStop::handle_event()
 }
 
 
+BatchRenderWarning::BatchRenderWarning(BatchRenderThread *thread, int x, int y)
+ : BC_CheckBox(x, y, thread->warn, _("warn if jobs/session mismatched"))
+{
+       this->thread = thread;
+}
+
+int BatchRenderWarning::handle_event()
+{
+       thread->warn = get_value();
+       return 1;
+}
+
+
 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
        int x,
        int y)