X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmain.C;h=e67dd2f4b5a8b30a182a1f65eb1e178c5242cf18;hb=875ae826327bf25abdaffe1db339aabd622addc8;hp=84a3cad3422b807b4f4246d0fe3c702caa438d1e;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/main.C b/cinelerra-5.1/cinelerra/main.C index 84a3cad3..e67dd2f4 100644 --- a/cinelerra-5.1/cinelerra/main.C +++ b/cinelerra-5.1/cinelerra/main.C @@ -18,11 +18,12 @@ * */ +#include "aboutprefs.h" #include "arraylist.h" #include "batchrender.h" #include "bcsignals.h" #include "edl.h" -#include "file.inc" +#include "file.h" #include "filexml.h" #include "filesystem.h" #include "language.h" @@ -35,15 +36,23 @@ #include "pluginserver.h" #include "preferences.h" #include "renderfarmclient.h" +#include "units.h" #include "versioninfo.h" #include #include #include -#define PACKAGE "cinelerra" -#define LOCALEDIR "/locale/" - +#ifdef LEAKER +#define STRC(v) printf("==new %p from %p sz %jd\n", v, __builtin_return_address(0), n) +#define STRD(v) printf("==del %p from %p\n", v, __builtin_return_address(0)) +void *operator new(size_t n) { void *vp = malloc(n); STRC(vp); bzero(vp,n); return vp; } +void operator delete(void *t) { STRD(t); free(t); } +void operator delete(void *t,size_t n) { STRD(t); free(t); } +void *operator new[](size_t n) { void *vp = malloc(n); STRC(vp); bzero(vp,n); return vp; } +void operator delete[](void *t) { STRD(t); free(t); } +void operator delete[](void *t,size_t n) { STRD(t); free(t); } +#endif enum { @@ -80,7 +89,7 @@ public: //PRINT_TRACE mwindow->load_filenames(filenames, LOADMODE_REPLACE); //PRINT_TRACE - if(filenames->size() == 1) + if( filenames->size() == 1 ) mwindow->gui->mainmenu->add_load(filenames->get(0)); //PRINT_TRACE mwindow->gui->unlock_window(); @@ -105,45 +114,21 @@ int main(int argc, char *argv[]) char deamon_path[BCTEXTLEN]; char config_path[BCTEXTLEN]; char batch_path[BCTEXTLEN]; - char locale_path[BCTEXTLEN]; - char exe_path[BCTEXTLEN]; - char env_path[BCTEXTLEN]; int nice_value = 20; + int load_perpetual = 1; config_path[0] = 0; batch_path[0] = 0; deamon_path[0] = 0; - EDL::id_lock = new Mutex("EDL::id_lock"); - - 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); - -// detect an UTF-8 locale and try to use a non-Unicode locale instead -// <---Beginning of dirty hack -// This hack will be removed as soon as Cinelerra is UTF-8 compliant -// char *s, *language; - -// Query user locale -// if ((s = getenv("LC_ALL")) || -// (s = getenv("LC_MESSAGES")) || -// (s = getenv("LC_CTYPE")) || -// (s = getenv ("LANG"))) -// { -// Test if user locale is set to Unicode -// if (strstr(s, ".UTF-8")) -// { -// extract language from language-charset@variant -// language = strtok (s, ".@"); -// set language as the default locale -// setenv("LANG", language, 1); -// } -// } -// End of dirty hack ---> - - bindtextdomain (PACKAGE, locale_path); - textdomain (PACKAGE); - setlocale (LC_MESSAGES, ""); + Units::init(); + + File::init_cin_path(); + const char *locale_path = File::get_locale_path(); + const char *cin = File::get_cin(); + + bindtextdomain(cin, locale_path); + textdomain(cin); + setlocale(LC_MESSAGES, ""); + #ifdef X_HAVE_UTF8_STRING char *loc = setlocale(LC_CTYPE, ""); if( loc ) { @@ -153,24 +138,24 @@ int main(int argc, char *argv[]) // Extract from locale language & region char locbuf[32], *p; locbuf[0] = 0; - if((p = strchr(loc, '.')) != 0 && (p - loc) < (int)sizeof(locbuf)-1) { + if( (p = strchr(loc, '.')) != 0 && (p - loc) < (int)sizeof(locbuf)-1 ) { strncpy(locbuf, loc, p - loc); locbuf[p - loc] = 0; } - else if(strlen(loc) < sizeof(locbuf)-1) + else if( strlen(loc) < sizeof(locbuf)-1 ) strcpy(locbuf, loc); // Locale 'C' does not give useful language info - assume en - if(!locbuf[0] || locbuf[0] == 'C') + if( !locbuf[0] || locbuf[0] == 'C' ) strcpy(locbuf, "en"); - if((p = strchr(locbuf, '_')) && p - locbuf < LEN_LANG) { + if( (p = strchr(locbuf, '_')) && p - locbuf < LEN_LANG ) { *p++ = 0; strcpy(BC_Resources::language, locbuf); - if(strlen(p) < LEN_LANG) + if( strlen(p) < LEN_LANG ) strcpy(BC_Resources::region, p); } - else if(strlen(locbuf) < LEN_LANG) + else if( strlen(locbuf) < LEN_LANG ) strcpy(BC_Resources::language, locbuf); } else @@ -183,88 +168,62 @@ int main(int argc, char *argv[]) int load_backup = 0; int start_remote_control = 0; - for(int i = 1; i < argc; i++) - { - if(!strcmp(argv[i], "-h")) - { + for( int i = 1; i < argc; i++ ) { + if( !strcmp(argv[i], "-h") ) { operation = DO_USAGE; } - else - if(!strcmp(argv[i], "-z")) - { + else if( !strcmp(argv[i], "-z") ) { start_remote_control = 1; } - else - if(!strcmp(argv[i], "-r")) - { + else if( !strcmp(argv[i], "-r") ) { operation = DO_BATCHRENDER; - if(argc > i + 1) - { - if(argv[i + 1][0] != '-') - { + if( argc > i + 1 ) { + if( argv[i + 1][0] != '-' ) { strcpy(batch_path, argv[i + 1]); i++; } } } - else - if(!strcmp(argv[i], "-c")) - { - if(argc > i + 1) - { + else if( !strcmp(argv[i], "-c") ) { + if( argc > i + 1 ) { strcpy(config_path, argv[i + 1]); i++; } - else - { + else { fprintf(stderr, _("%s: -c needs a filename.\n"), argv[0]); } } - else - if(!strcmp(argv[i], "-d") || !strcmp(argv[i], "-f")) - { - if(!strcmp(argv[i], "-d")) - operation = DO_DEAMON; - else - operation = DO_DEAMON_FG; - - if(argc > i + 1) - { - if(atol(argv[i + 1]) > 0) - { + else if( !strcmp(argv[i], "-d") || !strcmp(argv[i], "-f") ) { + operation = !strcmp(argv[i], "-d") ? DO_DEAMON : DO_DEAMON_FG; + if( argc > i + 1 ) { + if( atol(argv[i + 1]) > 0 ) { deamon_port = atol(argv[i + 1]); i++; } } } - else - if(!strcmp(argv[i], "-b")) - { + else if( !strcmp(argv[i], "-b") ) { operation = DO_BRENDER; - if(i > argc - 2) - { + if( i > argc - 2 ) { fprintf(stderr, _("-b may not be used by the user.\n")); exit(1); } else strcpy(deamon_path, argv[i + 1]); } - else - if(!strcmp(argv[i], "-n")) - { - if(argc > i + 1) - { + else if( !strcmp(argv[i], "-n") ) { + if( argc > i + 1 ) { nice_value = atol(argv[i + 1]); i++; } } - else - if(!strcmp(argv[i], "-x")) - { + else if( !strcmp(argv[i], "-x") ) { load_backup = 1; } - else - { + else if( !strcmp(argv[i], "-S") ) { + load_perpetual = 0; + } + else { char *new_filename; new_filename = new char[BCTEXTLEN]; strcpy(new_filename, argv[i]); @@ -275,13 +234,10 @@ int main(int argc, char *argv[]) - if(operation == DO_GUI || - operation == DO_DEAMON || - operation == DO_DEAMON_FG || - operation == DO_USAGE || - operation == DO_BATCHRENDER) { + if( operation == DO_GUI || + operation == DO_DEAMON || operation == DO_DEAMON_FG || + operation == DO_USAGE || operation == DO_BATCHRENDER) { - fprintf(stderr, PROGRAM_NAME " " CINELERRA_VERSION); #ifndef REPOMAINTXT #define REPOMAINTXT "" #endif @@ -291,42 +247,38 @@ int main(int argc, char *argv[]) #ifndef COPYRIGHTTEXT2 #define COPYRIGHTTEXT2 "" #endif -#ifndef COMPILEDATE -#define COMPILEDATE "" -#endif - fprintf(stderr, REPOMAINTXT COPYRIGHTTEXT1 COPYRIGHTTEXT2 COMPILEDATE - PROGRAM_NAME " is free software, covered by the GNU General Public License,\n" + fprintf(stderr, "%s %s - %s\n%s", + PROGRAM_NAME,CINELERRA_VERSION, AboutPrefs::build_timestamp, + REPOMAINTXT COPYRIGHTTEXT1 COPYRIGHTTEXT2); + fprintf(stderr, "%s is free software, covered by the GNU General Public License,\n" "and you are welcome to change it and/or distribute copies of it under\n" - "certain conditions. There is absolutely no warranty for " PROGRAM_NAME ".\n\n"); + "certain conditions. There is absolutely no warranty for %s.\n\n", + PROGRAM_NAME, PROGRAM_NAME); } - switch(operation) - { + switch( operation ) { case DO_USAGE: printf(_("\nUsage:\n")); printf(_("%s [-f] [-c configuration] [-d port] [-n nice] [-r batch file] [filenames]\n\n"), argv[0]); printf(_("-d = Run in the background as renderfarm client. The port (400) is optional.\n")); printf(_("-f = Run in the foreground as renderfarm client. Substitute for -d.\n")); printf(_("-n = Nice value if running as renderfarm client. (20)\n")); - printf(_("-c = Configuration file to use instead of %s%s.\n"), - BCASTDIR, - CONFIG_FILE); - printf(_("-r = batch render the contents of the batch file (%s%s) with no GUI. batch file is optional.\n"), - BCASTDIR, - BATCH_PATH); + printf(_("-c = Configuration file to use instead of %s/%s.\n"), + File::get_config_path(), CONFIG_FILE); + printf(_("-r = batch render the contents of the batch file (%s/%s) with no GUI. batch file is optional.\n"), + File::get_config_path(), BATCH_PATH); + printf(_("-S = do not reload perpetual session\n")); + printf(_("-x = reload from backup\n")); printf(_("filenames = files to load\n\n\n")); exit(0); break; case DO_DEAMON: - case DO_DEAMON_FG: - { - if(operation == DO_DEAMON) - { + case DO_DEAMON_FG: { + if( operation == DO_DEAMON ) { int pid = fork(); - if(pid) - { + if( pid ) { // Redhat 9 requires _exit instead of exit here. _exit(0); } @@ -337,36 +289,32 @@ int main(int argc, char *argv[]) nice_value, config_path); client.main_loop(); - break; - } + break; } // Same thing without detachment - case DO_BRENDER: - { + case DO_BRENDER: { RenderFarmClient client(0, deamon_path, 20, config_path); client.main_loop(); - break; - } + break; } - case DO_BATCHRENDER: - { + case DO_BATCHRENDER: { BatchRenderThread *thread = new BatchRenderThread; thread->start_rendering(config_path, batch_path); - break; - } + break; } - case DO_GUI: - { + case DO_GUI: { int restart = 0, done = 0; while( !done ) { BC_WindowBase::get_resources()->vframe_shm = 0; MWindow mwindow; mwindow.create_objects(1, !filenames.total, config_path); CommandLineThread *thread = 0; + if( mwindow.preferences->perpetual_session && load_perpetual ) + mwindow.load_undo_data(); //SET_TRACE // load the initial files on seperate tracks // use a new thread so it doesn't block the GUI @@ -401,6 +349,8 @@ int main(int argc, char *argv[]) done = 1; mwindow.save_defaults(); + if( mwindow.preferences->perpetual_session ) + mwindow.save_undo_data(); //PRINT_TRACE filenames.remove_all_objects(); delete thread; @@ -418,14 +368,13 @@ int main(int argc, char *argv[]) av[ac++] = 0; execv(exe_path, av); } - } //SET_TRACE DISABLE_BUFFER - break; + break; } } filenames.remove_all_objects(); - delete EDL::id_lock; EDL::id_lock = 0; + Units::finit(); return 0; }