batchrender hang on close, apply pref saves defaults, overwrite/splice tweaks, specif...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / mwindow.C
index 6ad64376e6b3e47839d20d5adae6fdd49d495d3a..c65f99f21167bf5c15932b3cd44c4196638d3c5e 100644 (file)
@@ -210,7 +210,6 @@ MWindow::MWindow()
        strcpy(cin_lang,"en");
        channeldb_buz =  new ChannelDB;
        channeldb_v4l2jpeg =  new ChannelDB;
-       //file_server = 0;
        plugin_guis = 0;
        dead_plugins = 0;
        keyframe_threads = 0;
@@ -319,7 +318,6 @@ MWindow::~MWindow()
        delete gwindow;         gwindow = 0;
        delete cwindow;         cwindow = 0;
        delete gui;             gui = 0;
-       //delete file_server;  file_server = 0; // reusable
        delete mainindexes;     mainindexes = 0;
        delete mainprogress;    mainprogress = 0;
        delete audio_cache;     audio_cache = 0;  // delete the cache after the assets
@@ -562,6 +560,9 @@ int MWindow::load_plugin_index(MWindow *mwindow, const char *index_path, const c
                case PLUGIN_TYPE_FFMPEG: {
                        server = new_ffmpeg_server(mwindow, path);
                        break; }
+               case PLUGIN_TYPE_LV2: {
+                       server = new_lv2_server(mwindow, path);
+                       break; }
                }
                if( !server ) continue;
                plugins.append(server);
@@ -630,6 +631,7 @@ int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences)
        fprintf(fp, "%s\n", plugin_path);
        init_plugin_index(mwindow, preferences, fp, plugin_path);
        init_ffmpeg_index(mwindow, preferences, fp);
+       init_lv2_index(mwindow, preferences, fp);
        fclose(fp);
        return load_plugin_index(mwindow, index_path, plugin_path);
 }
@@ -676,25 +678,6 @@ void MWindow::init_plugin_index(MWindow *mwindow, Preferences *preferences,
        scan_plugin_index(mwindow, preferences, fp, plugin_dir, ".", idx);
 }
 
-int MWindow::init_ladspa_index(MWindow *mwindow, Preferences *preferences,
-       const char *index_path, const char *plugin_dir)
-{
-       char plugin_path[BCTEXTLEN], *path = FileSystem::basepath(plugin_dir);
-       strcpy(plugin_path, path);  delete [] path;
-       printf("init ladspa index: %s\n", plugin_dir);
-       FILE *fp = fopen(index_path,"w");
-       if( !fp ) {
-               fprintf(stderr,_("MWindow::init_ladspa_index: "
-                       "can't create plugin index: %s\n"), index_path);
-               return 1;
-       }
-       fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
-       fprintf(fp, "%s\n", plugin_dir);
-       init_plugin_index(mwindow, preferences, fp, plugin_path);
-       fclose(fp);
-       return 0;
-}
-
 void MWindow::scan_plugin_index(MWindow *mwindow, Preferences *preferences, FILE *fp,
        const char *plug_dir, const char *plug_path, int &idx)
 {
@@ -898,10 +881,25 @@ int MWindow::plugin_exists(char *plugin_path)
        return !plugindb ? 0 : plugin_exists(plugin_path, *plugindb);
 }
 
+void MWindow::remove_plugin_index()
+{
+       char index_path[BCTEXTLEN];
+       MWindow::create_defaults_path(index_path, PLUGIN_FILE);
+       ::remove(index_path);
+}
+
 void MWindow::init_preferences()
 {
        preferences = new Preferences;
        preferences->load_defaults(defaults);
+       const char *lv2_path = getenv("LV2_PATH");
+       if( lv2_path && strcmp(lv2_path, preferences->lv2_path) ) {
+               strncpy(preferences->lv2_path, lv2_path, sizeof(preferences->lv2_path));
+               remove_plugin_index();
+       }
+       else if( !lv2_path && preferences->lv2_path[0] ) {
+               File::setenv_path("LV2_PATH",preferences->lv2_path, 0);
+       }
        session = new MainSession(this);
        session->load_defaults(defaults);
        // set x11_host, screens, window_config
@@ -1630,37 +1628,49 @@ void MWindow::set_brender_active(int v, int update)
 
 int MWindow::has_commercials()
 {
+#ifdef HAVE_COMMERCIAL
        return theme->use_commercials;
+#else
+       return 0;
+#endif
 }
 
 void MWindow::init_commercials()
 {
+#ifdef HAVE_COMMERCIAL
        if( !commercials ) {
                commercials = new Commercials(this);
                commercial_active = 0;
        }
        else
                commercials->add_user();
+#endif
 }
 
 void MWindow::commit_commercial()
 {
+#ifdef HAVE_COMMERCIAL
        if( !commercial_active ) return;
        commercial_active = 0;
        if( !commercials ) return;
        commercials->commitDb();
+#endif
 }
 
 void MWindow::undo_commercial()
 {
+#ifdef HAVE_COMMERCIAL
        if( !commercial_active ) return;
        commercial_active = 0;
        if( !commercials ) return;
        commercials->undoDb();
+#endif
 }
 
 int MWindow::put_commercial()
 {
+       int result = 0;
+#ifdef HAVE_COMMERCIAL
        double start = edl->local_session->get_selectionstart();
        double end = edl->local_session->get_selectionend();
        if( start >= end ) return 0;
@@ -1668,7 +1678,6 @@ int MWindow::put_commercial()
        const char *errmsg = 0;
        int count = 0;
        Tracks *tracks = edl->tracks;
-       int result = 0;
        //check it
        for(Track *track=tracks->first; track && !errmsg; track=track->next) {
                if( track->data_type != TRACK_VIDEO ) continue;
@@ -1721,6 +1730,7 @@ int MWindow::put_commercial()
                undo_commercial();
                result = 1;
        }
+#endif
        return result;
 }
 
@@ -2342,9 +2352,6 @@ void MWindow::create_objects(int want_gui,
        BC_Resources::init_fontconfig(string);
        if(debug) PRINT_TRACE
 
-// Initialize before too much else is running
-// Preferences & theme are required for building MPEG table of contents
-
 // Default project created here
        init_edl();
        if(debug) PRINT_TRACE