upgrade dmp output
[goodguy/history.git] / cinelerra-5.1 / cinelerra / mwindow.C
index cdf80b206eebfe6790a595886f76791041903f00..de49bcf436aeead88135ae27e3e7b18bbc71e465 100644 (file)
 #include "transition.h"
 #include "transportque.h"
 #include "vframe.h"
+#include "versioninfo.h"
 #include "videodevice.inc"
 #include "videowindow.h"
 #include "vplayback.h"
@@ -213,6 +214,7 @@ MWindow::MWindow()
        restart_status = 0;
        screens = 1;
        in_destructor = 0;
+       warn_version = 1;
 }
 
 
@@ -235,6 +237,7 @@ MWindow::~MWindow()
        delete create_bd;       create_bd = 0;
        delete create_dvd;      create_dvd = 0;
        delete batch_render;    batch_render = 0;
+       delete render;          render = 0;
        commit_commercial();
        if( commercials && !commercials->remove_user() ) commercials = 0;
 
@@ -292,15 +295,13 @@ MWindow::~MWindow()
        finit_error();
        keyframe_threads->remove_all_objects();
        colormodels.remove_all_objects();
-       delete gui;             gui = 0;
-       delete render;          render = 0;
        delete awindow;         awindow = 0;
        delete lwindow;         lwindow = 0;
        delete twindow;         twindow = 0;
        delete wwindow;         wwindow = 0;
        delete gwindow;         gwindow = 0;
-       // must be last or nouveau chokes
        delete cwindow;         cwindow = 0;
+       delete gui;             gui = 0;
        //delete file_server;  file_server = 0; // reusable
        delete mainindexes;     mainindexes = 0;
        delete mainprogress;    mainprogress = 0;
@@ -340,8 +341,8 @@ MWindow::~MWindow()
 
 void MWindow::quit(int unlock)
 {
-       stop_playback(1);
        if(unlock) gui->unlock_window();
+       stop_playback(1);
 
        brender_lock->lock("MWindow::quit");
        delete brender;         brender = 0;
@@ -369,7 +370,7 @@ void MWindow::create_defaults_path(char *string, const char *config_file)
 // set the .bcast path
        FileSystem fs;
 
-       sprintf(string, "%s", BCASTDIR);
+       sprintf(string, "%s/", File::get_config_path());
        fs.complete_path(string);
        if(!fs.is_dir(string))
                fs.create_dir(string);
@@ -597,8 +598,7 @@ int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
        char *path = getenv("LADSPA_PATH");
        char ladspa_path[BCTEXTLEN];
        if( !path ) {
-               get_exe_path(ladspa_path);
-               strcat(ladspa_path, "/ladspa");
+               strncpy(ladspa_path, File::get_ladspa_path(), sizeof(ladspa_path));
                path = ladspa_path;
        }
        for( int len=0; *path; path+=len ) {
@@ -903,6 +903,11 @@ void MWindow::show_warning(int *do_warning, const char *text)
        wwindow->show_warning(do_warning, text);
 }
 
+int MWindow::wait_warning()
+{
+       return wwindow->wait_result();
+}
+
 void MWindow::init_theme()
 {
        Timer timer;
@@ -1496,7 +1501,29 @@ SET_TRACE
 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
                                xml_file.read_from_file(filenames->get(i));
 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
-
+                               const char *cin_version = 0;
+                               while( !xml_file.read_tag() ) {
+                                       if( xml_file.tag.title_is("EDL") ) {
+                                               cin_version = xml_file.tag.get_property("VERSION");
+                                               break;
+                                       }
+                               }
+                               xml_file.rewind();
+                               if( !cin_version ) {
+                                       eprintf(_("XML file %s\n not from cinelerra."),filenames->get(i));
+                                       char string[BCTEXTLEN];
+                                       sprintf(string,_("Unknown %s"), filenames->get(i));
+                                       gui->show_message(string);
+                                       result = 1;
+                                       break;
+                               }
+                               if( strcmp(cin_version, CINELERRA_VERSION) ) {
+                                       char string[BCTEXTLEN];
+                                       snprintf(string, sizeof(string),
+                                                _("Warning: XML from cinelerra version %s\n"
+                                               "Session data may be incompatible."), cin_version);
+                                       show_warning(&preferences->warn_version, string);
+                               }
                                if(load_mode == LOADMODE_NESTED)
                                {
 // Load temporary EDL for nesting.
@@ -2434,7 +2461,7 @@ void MWindow::hide_plugin(Plugin *plugin, int lock)
                        ptr->hide_gui();
                        delete_plugin(ptr);
 //sleep(1);
-//                     return;
+                       return;
                }
        }
        if(lock) plugin_gui_lock->unlock();
@@ -2876,17 +2903,18 @@ void MWindow::save_backup()
        FileXML file;
        edl->optimize();
        edl->set_path(session->filename);
-       edl->save_xml(&file, BACKUP_PATH, 0, 0);
+       char backup_path[BCTEXTLEN];
+       snprintf(backup_path, sizeof(backup_path), "%s/%s",
+               File::get_config_path(), BACKUP_FILE);
+       edl->save_xml(&file, backup_path, 0, 0);
        file.terminate_string();
-       char path[BCTEXTLEN];
        FileSystem fs;
-       strcpy(path, BACKUP_PATH);
-       fs.complete_path(path);
+       fs.complete_path(backup_path);
 
-       if(file.write_to_file(path))
+       if(file.write_to_file(backup_path))
        {
                char string2[256];
-               sprintf(string2, _("Couldn't open %s for writing."), BACKUP_PATH);
+               sprintf(string2, _("Couldn't open %s for writing."), backup_path);
                gui->show_message(string2);
        }
 }
@@ -2896,13 +2924,14 @@ void MWindow::load_backup()
        ArrayList<char*> path_list;
        path_list.set_array_delete();
        char *out_path;
-       char string[BCTEXTLEN];
-       strcpy(string, BACKUP_PATH);
+       char backup_path[BCTEXTLEN];
+       snprintf(backup_path, sizeof(backup_path), "%s/%s",
+               File::get_config_path(), BACKUP_FILE);
        FileSystem fs;
-       fs.complete_path(string);
+       fs.complete_path(backup_path);
 
-       path_list.append(out_path = new char[strlen(string) + 1]);
-       strcpy(out_path, string);
+       path_list.append(out_path = new char[strlen(backup_path) + 1]);
+       strcpy(out_path, backup_path);
 
        load_filenames(&path_list, LOADMODE_REPLACE, 0);
        edl->local_session->clip_title[0] = 0;
@@ -2925,6 +2954,9 @@ int MWindow::create_aspect_ratio(float &w, float &h, int width, int height)
 {
        w = 1;  h = 1;
        if(!width || !height) return 1;
+       if( width == 720 && (height == 480 || height == 576) ) {
+               w = 4;  h = 3;  return 0; // for NTSC and PAL
+       }
        double ar = (double)width / height;
 // square-ish pixels
        if( EQUIV(ar, 1.0000) ) return 0;
@@ -3114,13 +3146,23 @@ void MWindow::dump_exe(FILE *fp)
 {
         char proc_path[BCTEXTLEN], exe_path[BCTEXTLEN];
         sprintf(proc_path, "/proc/%d/exe", (int)getpid());
-        int ret = readlink(proc_path, exe_path, sizeof(exe_path));
-       if( ret < 0 ) { fprintf(fp,"readlink: %m\n"); return; }
-       exe_path[ret] = 0;
+
+        int ret = -1, n = 100;
+       for( int len; (len=readlink(proc_path, exe_path, sizeof(exe_path)))>0; --n ) {
+               exe_path[len] = 0;  strcpy(proc_path, exe_path);
+               ret = 0;
+       }
+       if( n < 0 || ret < 0 ) { fprintf(fp,"readlink: %m\n"); return; }
+
        struct stat st;
-       if( stat(exe_path,&st) ) { fprintf(fp,"stat: %m\n"); return; }
-       fprintf(fp, "path: %s = %9jd bytes\n",exe_path,st.st_size);
-       int fd = open(exe_path,O_RDONLY+O_NONBLOCK);
+       if( stat(proc_path,&st) ) { fprintf(fp,"stat: %m\n"); return; }
+       fprintf(fp, "path: %s = %9jd bytes\n",proc_path,st.st_size);
+       struct tm *tm = localtime(&st.st_mtime);
+       char mtime[256];
+       strftime(mtime, sizeof(mtime), "%F %T", tm);
+       fprintf(fp,"mtime: %s\n", mtime);
+
+       int fd = open(proc_path,O_RDONLY+O_NONBLOCK);
        if( fd < 0 ) { fprintf(fp,"open: %m\n"); return; }
        uint8_t *bfr = 0;
        int64_t bfrsz = 0;