repair default keyframe load, tweak init default histogram threshold
[goodguy/history.git] / cinelerra-5.1 / cinelerra / swindow.C
index 1d33f4b15224e166b8f3293a2c3e649391e8d55a..1604d8dbf371804fb36e6d1f938a256abc940e49 100644 (file)
@@ -139,6 +139,7 @@ int SWindowSaveFile::handle_event()
 
 void SWindowGUI::create_objects()
 {
+       lock_window("SWindowGUI::create_objects");
        int x = 10, y = 10;
        BC_Title *title = new BC_Title(x, y, _("Path:"));
        add_subwindow(title);
@@ -197,6 +198,7 @@ void SWindowGUI::create_objects()
        add_subwindow(ok);
        cancel = new SWindowCancel(this, cancel_x, cancel_y);
        add_subwindow(cancel);
+       unlock_window();
 }
 
 void SWindowGUI::load()
@@ -356,6 +358,7 @@ void SWindowGUI::set_script_pos(int64_t entry_no, int text_no)
 
 int SWindowGUI::load_selection(int pos, int row)
 {
+       if( pos < 0 || pos >= script.size() ) return 1;
        ScriptLines *texts = script[pos];
        char *rp = texts->get_text_row(row);
        if( !rp || *rp == '=' || *rp == '*' || *rp=='\n' ) return 1;
@@ -742,7 +745,7 @@ void ScriptEntry::set_text(char *text, int isz)
 
 int ScriptEntry::handle_event()
 {
-       if( sw_gui->get_button_down() &&
+       if( ttext && sw_gui->get_button_down() &&
            sw_gui->get_buttonpress() == 1 &&
            sw_gui->get_triple_click() ) {
                int ibeam = get_ibeam_letter(), row = 0;
@@ -794,6 +797,8 @@ void SWindowGUI::load_script()
                return;
        }
        load_script(fp);
+       script_text_no = -1;
+       load_selection(script_entry_no=0, 0);
 }
 
 void SWindowGUI::load_script(FILE *fp)
@@ -815,7 +820,6 @@ void SWindowGUI::load_script(FILE *fp)
        script_scroll->update_length(script.size(), script_entry_no, hw, 0);
        script_position->update(script_entry_no);
        script_position->set_boundaries((int64_t)0, (int64_t)script.size()-1);
-
        fclose(fp);
 }
 
@@ -834,9 +838,11 @@ void SWindowGUI::save_spumux_data()
        for( Track *track=tracks->first; track; track=track->next ) {
                if( track->data_type != TRACK_SUBTITLE ) continue;
                if( !track->record ) continue;
-               char *cp = track_title;
-               for( char *bp=track->title; *bp; ++bp,++cp )
-                       *cp = !isalnum(*bp) ? '_' : *bp;
+               char *cp = track_title, *ep = cp+sizeof(track_title)-6;
+               for( const char *bp=track->title; cp<ep && *bp!=0; ) {
+                       int b = butf8(bp), c = !iswalnum(b) ? '_' : b;
+                       butf8(c, cp);
+               }
                *cp = 0;
                snprintf(ext,len,"-%s.udvd",track_title);
                FILE *fp = fopen(filename, "w");