#include "batchrender.h"
#include "bcsignals.h"
#include "edl.h"
+#include "file.inc"
#include "filexml.h"
-#include "fileserver.h"
#include "filesystem.h"
#include "language.h"
#include "langinfo.h"
};
-void get_exe_path(char *result)
-{
-// Get executable path
- pid_t pid = getpid();
- char proc_path[BCTEXTLEN];
- int len = 0;
- result[0] = 0;
- sprintf(proc_path, "/proc/%d/exe", pid);
- if((len = readlink(proc_path, result, BCTEXTLEN)) >= 0)
- {
- result[len] = 0;
-//printf("Preferences::Preferences %d %s\n", __LINE__, result);
- char *ptr = strrchr(result, '/');
- if(ptr) *ptr = 0;
- }
-
-}
-
-
int main(int argc, char *argv[])
{
// handle command line arguments first
char batch_path[BCTEXTLEN];
char locale_path[BCTEXTLEN];
char exe_path[BCTEXTLEN];
+ char env_path[BCTEXTLEN];
int nice_value = 20;
- int start_remote_control = 0;
config_path[0] = 0;
batch_path[0] = 0;
deamon_path[0] = 0;
get_exe_path(exe_path);
+ snprintf(env_path, sizeof(env_path), "CINELERRA_PATH=%s", exe_path);
+ putenv(env_path);
sprintf(locale_path, "%s%s", exe_path, LOCALEDIR);
+ int load_backup = 0;
+ int start_remote_control = 0;
for(int i = 1; i < argc; i++)
{
}
}
else
+ if(!strcmp(argv[i], "-x"))
+ {
+ load_backup = 1;
+ }
+ else
{
char *new_filename;
new_filename = new char[BCTEXTLEN];
BatchRenderThread *thread = new BatchRenderThread;
thread->start_rendering(config_path,
batch_path);
- delete MWindow::file_server;
break;
}
case DO_GUI:
{
- int done = 0;
- int load_backup = 0;
+ int restart = 0, done = 0;
while( !done ) {
BC_WindowBase::get_resources()->vframe_shm = 0;
MWindow mwindow;
mwindow.start();
mwindow.run();
//PRINT_TRACE
- if( mwindow.reload() )
- start_remote_control =
- mwindow.gui->remote_control->is_active();
- else
- done = 1;
- if( !done ) {
+ restart = mwindow.restart();
+ if( restart ) {
mwindow.save_backup();
load_backup = 1;
+ start_remote_control =
+ mwindow.gui->remote_control->is_active();
}
+ if( restart <= 0 )
+ done = 1;
mwindow.save_defaults();
//PRINT_TRACE
filenames.remove_all_objects();
}
+
+ if( restart < 0 ) {
+ char exe_path[BCTEXTLEN];
+ int len = readlink("/proc/self/exe", exe_path, sizeof(exe_path)-1);
+ if( len < 0 ) break;
+ exe_path[len] = 0;
+ char *av[4] = { 0, }; int ac = 0;
+ av[ac++] = exe_path;
+ if( load_backup ) av[ac++] = (char*) "-x";
+ if( start_remote_control ) av[ac++] = (char*) "-z";
+ av[ac++] = 0;
+ execv(exe_path, av);
+ }
+ }
//SET_TRACE
DISABLE_BUFFER
- break;
- }
+ break;
}
return 0;