change thread join strategy, fix a few leaks, fix a few bugs
authorGood Guy <good1.2guy@gmail.com>
Mon, 11 Apr 2016 22:30:06 +0000 (16:30 -0600)
committerGood Guy <good1.2guy@gmail.com>
Mon, 11 Apr 2016 22:30:06 +0000 (16:30 -0600)
44 files changed:
cinelerra-5.1/cinelerra/androidcontrol.C
cinelerra-5.1/cinelerra/assetedit.C
cinelerra-5.1/cinelerra/awindow.C
cinelerra-5.1/cinelerra/brender.C
cinelerra-5.1/cinelerra/channeledit.C
cinelerra-5.1/cinelerra/channelinfo.C
cinelerra-5.1/cinelerra/commercials.C
cinelerra-5.1/cinelerra/cwindow.C
cinelerra-5.1/cinelerra/dbwindow.C
cinelerra-5.1/cinelerra/device1394input.C
cinelerra-5.1/cinelerra/device1394output.C
cinelerra-5.1/cinelerra/devicev4l2base.C
cinelerra-5.1/cinelerra/dv1394input.C
cinelerra-5.1/cinelerra/ffmpeg.C
cinelerra-5.1/cinelerra/fileffmpeg.C
cinelerra-5.1/cinelerra/filethread.C
cinelerra-5.1/cinelerra/formattools.C
cinelerra-5.1/cinelerra/gwindow.C
cinelerra-5.1/cinelerra/iec61883input.C
cinelerra-5.1/cinelerra/iec61883output.C
cinelerra-5.1/cinelerra/levelwindow.C
cinelerra-5.1/cinelerra/mainundo.C
cinelerra-5.1/cinelerra/mwindow.C
cinelerra-5.1/cinelerra/pluginfclient.C
cinelerra-5.1/cinelerra/recordgui.C
cinelerra-5.1/cinelerra/remotecontrol.C
cinelerra-5.1/cinelerra/resourcethread.C
cinelerra-5.1/cinelerra/setformat.C
cinelerra-5.1/cinelerra/swindow.C
cinelerra-5.1/cinelerra/tracking.C
cinelerra-5.1/cinelerra/vdevicebuz.C
cinelerra-5.1/cinelerra/videowindow.C
cinelerra-5.1/guicast/bcclipboard.C
cinelerra-5.1/guicast/bcdragwindow.C
cinelerra-5.1/guicast/bcdragwindow.h
cinelerra-5.1/guicast/bclistbox.C
cinelerra-5.1/guicast/bclistbox.h
cinelerra-5.1/guicast/bcprogressbox.C
cinelerra-5.1/guicast/bcsynchronous.C
cinelerra-5.1/guicast/bcwindowbase.C
cinelerra-5.1/guicast/bcwindowbase.h
cinelerra-5.1/guicast/bcwindowevents.C
cinelerra-5.1/guicast/rotateframe.C
cinelerra-5.1/guicast/vicon.C

index 784dea2313a5732dc0e74953c037a22f729552a7..79008ac8a83f84c1be9d67776fcf78ba99a10329 100644 (file)
@@ -143,7 +143,7 @@ AndroidControl::~AndroidControl()
        if( Thread::running() ) {
                done = 1;
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 }
 
index eb76149b3b1eca5364e460a2165a4054ad36bc50..dbdabf36edb49a00bdea9cdc145d288135e4d606 100644 (file)
@@ -1036,8 +1036,8 @@ void DetailAssetThread::stop()
                dwindow->lock_window("DetailAssetThread::stop");
                dwindow->set_done(1);
                dwindow->unlock_window();
-               Thread::join();
        }
+       Thread::join();
 }
 
 void DetailAssetWindow::create_objects()
index be3cf27cf52e832f8e64514936874faf19834966..f6a87ed849d194815edb7c7144ae35036ada9338 100644 (file)
@@ -45,8 +45,8 @@ AWindow::~AWindow()
                gui->lock_window("AWindow::~AWindow");
                gui->set_done(0);
                gui->unlock_window();
-               Thread::join();
        }
+       Thread::join();
        delete asset_remove;
        delete asset_edit;
        delete label_edit;
index 35144b26ad38117bdadb80988a012ef9057be9e0..3a1e3f82e4c7e61d88af0a6c303170dbee5bd4d5 100644 (file)
@@ -93,9 +93,9 @@ TRACE("BRender::~BRender 5\n");
        {
                kill(master_pid, SIGKILL);
 TRACE("BRender::~BRender 6\n");
-               Thread::join();
 TRACE("BRender::~BRender 7\n");
        }
+       Thread::join();
 
 TRACE("BRender::~BRender 8\n");
        delete map_lock;
index 91b7c11b0f39b48067dc562aadd920f70c46c703..6e02639ebc029618e7fdf88b216da86c6fb540c8 100644 (file)
@@ -765,8 +765,8 @@ void ScanThread::stop()
        if( !interrupt ) {
 // Cancel previous job
                interrupt = 1;
-               Thread::join();
        }
+       Thread::join();
        if( progress ) {
                progress->stop_progress();
                delete progress;  progress = 0;
index 140f3d30e509848b7cb26d7045228b6f806a68fd..71469330cad7367b779e797064a7bbdc4c5df90f 100644 (file)
@@ -70,8 +70,8 @@ void ChanSearch::stop()
                if( gui ) gui->set_done(1);
                window_lock->unlock();
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 }
 
 void ChanSearch::run()
@@ -560,8 +560,8 @@ void ChannelProgress::stop()
        if( Thread::running() ) {
                done = 1;
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 }
 
 void ChannelProgress::run()
@@ -1050,8 +1050,8 @@ void ChannelThread::stop()
        if( Thread::running() ) {
                done = 1;
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 }
 
 ChannelThread::ChannelThread(ChannelInfoGUI *gui)
@@ -1655,8 +1655,8 @@ void ChannelInfo::stop()
                if( gui ) gui->stop(1);
                window_lock->unlock();
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 }
 
 void ChannelInfo::run()
index a08ec02921e1e058c1d07c78470d23affe75a9c3..2485f263fca69c0f7b96c91a36a74b02647bc1cf 100644 (file)
@@ -787,8 +787,8 @@ stop()
        if( running() ) {
                if( gui ) gui->set_done(1);
                cancel();
-               join();
        }
+       join();
 }
 
 void ScanStatus::
@@ -856,8 +856,8 @@ stop()
                done = 1;
                input_lock->unlock();
                cancel();
-               join();
        }
+       join();
        if( commercials && !commercials->remove_user() )
                commercials = 0;
 }
index cc5a2707cf716e71ee80605f4274d5fdd2cb63b4..c5009a0813233ab25a570e548d9004c8bf76f9cf 100644 (file)
@@ -65,8 +65,8 @@ CWindow::~CWindow()
 {
        if(gui && running()) {
                gui->set_done(0);
-               join();
        }
+       join();
        delete gui;  gui = 0;
        delete playback_engine;
        delete playback_cursor;
index c19b581e37e2a9763c9f264a053cd0af0a3852df..48768cd4bb487c8b2c0f60776c22c1564fe5851d 100644 (file)
@@ -87,8 +87,8 @@ stop()
                if( gui ) gui->set_done(1);
                window_lock->unlock();
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 }
 
 void DbWindow::
index 57d4e468ea35e0697b685c23f42592591b1daeab..2fa7c6f0badd73bec5c08aa098b27d61c34213db 100644 (file)
@@ -67,8 +67,8 @@ Device1394Input::~Device1394Input()
        {
                done = 1;
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 
        if(buffer)
        {
index f021a165b35585241c3a42cfd6b3768c2c4da611..6aa493e20dd376a143feb26cc29e41f8d626b7be 100644 (file)
@@ -79,8 +79,8 @@ Device1394Output::~Device1394Output()
                done = 1;
                start_lock->unlock();
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 
        if(buffer)
        {
index efc3c0616fdd7ceac574369f5242aa050098fa88..31a009b38fb9ea3b6c40303957dc646acfb4b6f6 100644 (file)
@@ -165,8 +165,8 @@ DeviceV4L2Put::~DeviceV4L2Put()
                done = 1;
                buffer_lock->unlock();
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
        delete buffer_lock;
        delete putq;
 }
@@ -709,8 +709,8 @@ void DeviceV4L2Base::close_dev()
                {
                        done = 1;
                        Thread::cancel();
-                       Thread::join();
                }
+               Thread::join();
                if(put_thread)
                {
                        delete put_thread;
index ebd18cf11807bca6415df5f9006a1f9c21c13fc2..f8dd1f3a5071dcaa015e52d739b41441fe4d2286 100644 (file)
@@ -38,8 +38,8 @@ DV1394Input::~DV1394Input()
        {
                done = 1;
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 
        if(fd > 0) close(fd);
 }
index ccf80afcbce0e94590c05696b9a165a73d7e1ec1..515657867a22e929a0f806ec321bee6c1a63a9ac 100644 (file)
@@ -1992,8 +1992,8 @@ void FFMPEG::stop_muxer()
        if( running() ) {
                done = 1;
                mux_lock->unlock();
-               join();
        }
+       join();
 }
 
 void FFMPEG::flow_off()
index ab856af041b7a9c0f1769fcffa5af8aa17319e85..660f750edd143038741c7dda5cfdd01678f1a79b 100644 (file)
@@ -668,10 +668,12 @@ int FileFFMPEG::get_index(IndexFile *index_file, MainProgressBar *progress_bar)
        if( ff->scan(index_state, &scan_position, &canceled) || canceled ) {
                index_state->reset_index();
                index_state->reset_markers();
-               return 1;
+               canceled = 1;
        }
 
        delete scan_progress;
+       if( canceled ) return 1;
+
        index_state->marker_status = MARKERS_READY;
        return index_state->create_index(index_path, asset);
 }
index c5b28785c03cd7f491adb61c1f5fb59d56a58b52..f8744545493919c33a26af82ecf0a34a130cfbf3 100644 (file)
@@ -501,8 +501,8 @@ int FileThread::stop_reading()
        {
                done = 1;
                read_wait_lock->unlock();
-               Thread::join();
        }
+       Thread::join();
        return 0;
 }
 
index d3685e02dc692babaa532a8e54a22ae7142d6094..28f4b556461f7a1337a9272df7c7f497dcaa7637 100644 (file)
@@ -493,14 +493,14 @@ void FormatTools::update(Asset *asset, int *strategy)
 void FormatTools::close_format_windows()
 {
 // This is done in ~file
-       if(aparams_thread && aparams_thread->running())
-       {
-               aparams_thread->file->close_window();
+       if( aparams_thread ) {
+               if( aparams_thread->running() )
+                       aparams_thread->file->close_window();
                aparams_thread->join();
        }
-       if(vparams_thread && vparams_thread->running())
-       {
-               vparams_thread->file->close_window();
+       if( vparams_thread ) {
+               if( vparams_thread->running() )
+                       vparams_thread->file->close_window();
                vparams_thread->join();
        }
 }
index 679dacade9c8d723e6279b1cb267ed12a96219db..bfa490d3bf35e97ae047dbc6edbc1814e23655ff 100644 (file)
@@ -34,8 +34,8 @@ GWindow::~GWindow()
 {
        if(gui && running()) {
                gui->set_done(0);
-               join();
        }
+       join();
        delete gui;  gui = 0;
 }
 
index cbdfe103406a6c2f348a0c189258dc28e3f49b77..8b41c92b56e277d47007cb0b87b945ca350e0bd1 100644 (file)
@@ -67,8 +67,8 @@ IEC61883Input::~IEC61883Input()
        if(Thread::running())
        {
                done = 1;
-               Thread::join();
        }
+       Thread::join();
 
        if(buffer)
        {
index a2fe2e1a824cdfccbb0cf85b0950917389ffe784..8997266f1dd75cfa43ec9d20a09479767e0f3582 100644 (file)
@@ -74,8 +74,8 @@ IEC61883Output::~IEC61883Output()
                done = 1;
                start_lock->unlock();
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 
        if(buffer)
        {
index f6a4de0133f1db0b7b766d58a185431d17aa9aab..11a74d7ae80df53a1cf2a9f714922a7ac3775887 100644 (file)
@@ -35,8 +35,8 @@ LevelWindow::~LevelWindow()
 {
        if(gui && running()) {
                gui->set_done(0);
-               join();
        }
+       join();
        delete gui;  gui = 0;
 }
 
index e688a06e3d4af5f44b81a85e9a47b1453de43f3c..668a301aa1a66f4747810c519e65bdf1929681b6 100644 (file)
@@ -305,6 +305,7 @@ int MainUndo::load_from_undo(FileXML *file, uint32_t load_flags)
                mwindow->mainindexes->add_next_asset(0, nested_edl);
        }
        mwindow->mainindexes->start_build();
+       mwindow->update_plugin_guis(1);
        return 0;
 }
 
index d9e916ef46a613c00079795ac9762c0b3296d330..f53dc4d65e587fd1493d423da837ba7928880cac 100644 (file)
@@ -3197,6 +3197,7 @@ int MWindow::run_script(FileXML *script)
 
 int MWindow::interrupt_indexes()
 {
+       mainprogress->cancelled = 1;
        mainindexes->interrupt_build();
        return 0;
 }
index 2a222cbe0b3a380308b00604b885de3866c8cb99..1bea7dd04ba1564c7fbbdfd748409e9c15f604c6 100644 (file)
@@ -521,6 +521,7 @@ PluginFClient::PluginFClient(PluginClient *plugin, const char *name)
 
 PluginFClient::~PluginFClient()
 {
+       delete ffilt;
 }
 
 bool PluginFClient::is_audio(AVFilter *fp)
index be290b3ee2362bf1c6989f01544376fae78f6991..64e2984f805d515f81de3475deb7dbdacd4c418b 100644 (file)
@@ -1044,8 +1044,8 @@ EndRecordThread::~EndRecordThread()
                window->lock_window("EndRecordThread::~EndRecordThread");
                window->set_done(1);
                window->unlock_window();
-               Thread::join();
        }
+       Thread::join();
 }
 
 void EndRecordThread::start(int is_ok)
@@ -1081,8 +1081,8 @@ RecordStartoverThread::~RecordStartoverThread()
                window->lock_window("RecordStartoverThread::~RecordStartoverThread");
                window->set_done(1);
                window->unlock_window();
-               Thread::join();
        }
+       Thread::join();
 }
 
 void RecordStartoverThread::run()
@@ -1382,8 +1382,8 @@ RecordStatusThread::~RecordStatusThread()
        {
                done = 1;
                input_lock->unlock();
-               Thread::join();
        }
+       Thread::join();
 }
 
 void RecordStatusThread::reset_video()
@@ -1537,8 +1537,8 @@ RecordGUIFlash::
                done = 1;
                flash_lock->unlock();
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
        delete flash_lock;
 }
 
index 5cd0f7eb05c7f8b0971977f5b3c4120cf5418b68..23dc4c45668014d02ba2305f7c51661fbeb1f7b5 100644 (file)
@@ -41,8 +41,8 @@ RemoteControl::~RemoteControl()
 {
        if( Thread::running() ) {
                remote_window->close(1);
-               Thread::join();
        }
+       Thread::join();
        delete gui;
        delete remote_window;
        delete active_lock;
index c14bf27b79ca0b7b36def8d5e1afc7aba6baf128..6aa27b99e125ff9c5ff9399b057609174a42726a 100644 (file)
@@ -338,8 +338,8 @@ void ResourceThread::stop()
                done = 1;
                interrupted = 1;
                draw_lock->unlock();
-               join();
        }
+       join();
 }
 
 
index 17550381bbf7072ec9011885eb5f9a3f0335bf18..ef0d3000813aef51bc1788e2446154483bd91d2a 100644 (file)
@@ -94,8 +94,8 @@ SetFormatThread::~SetFormatThread()
        if( running() ) {
                window->set_done(1);
                cancel();
-               join();
        }
+       join();
        delete window_lock;
 }
 
index 65799c4bba5ac82c55fc71ee4588c1535ed16dda..bacf80d75d10f15fa3b364f36a11da353999aba6 100644 (file)
@@ -342,8 +342,9 @@ int SWindowGUI::load_selection(int pos, int row)
                script_entry->set_text_row(0);
        }
        script_text_no = row;
-       char line[BCTEXTLEN], *bp = line, *cp = rp;
-       while( *cp && *cp!='\n' ) *bp++ = *cp++;
+       char line[BCTEXTLEN], *bp = line;
+       char *ep = bp+sizeof(line)-1, *cp = rp;
+       while( bp < ep && *cp && *cp!='\n' ) *bp++ = *cp++;
        *bp = 0;  bp = texts->text;
        int char1 = rp-bp, char2 = cp-bp;
        script_entry->set_selection(char1, char2, char2);
@@ -602,15 +603,15 @@ int ScriptLines::break_lines()
                        memmove(cp,sp,dp+1-sp);
                        used -= n;  dp -= n;  ep -= n;
                }
-               // constrain line_limit
-               if( (n=(ep-cp)/2) < limit2 || n > line_limit )
+               // target about half remaining line, constrain line_limit
+               if( (n=(ep-1-cp)/2) < limit2 || n > line_limit )
                        n = line_limit;
-               // search for last punct, last space
+               // search for last punct, last space before line_limit
                for( bp=cp, pp=sp=0; --n>=0 && cp<ep; ++cp ) {
                        if( ispunct(*cp) && isspace(*(cp+1)) ) pp = cp;
                        else if( isspace(*cp) ) sp = cp;
                }
-               // long enough to break
+               // line not empty
                if( cp < ep ) {
                        // first, after punctuation
                        if( pp && pp-bp >= limit4 )
@@ -731,10 +732,10 @@ int SWindowGUI::load_script_line(FILE *fp)
 
        for(;;) { // load non-blank lines
                //int len = strlen(line);
-               //if( cp[len-1] == '\n' ) cp[len-1] = 0;
+               //if( line[len-1] == '\n' ) line[len-1] = ' ';
                entry->append(line);
                char *cp = fgets(line,sizeof(line),fp);
-               if( !cp ) return 1;
+               if( !cp ) break;
                ++script_line_no;
                while( *cp && isspace(*cp) ) ++cp;
                if( !*cp ) break;
@@ -852,8 +853,8 @@ void SWindow::stop()
                if( gui ) gui->stop(1);
                window_lock->unlock();
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 }
 
 void SWindow::run()
index 1ca59993e9aa5a31ae383de3916b15200c041389..b2094970369b2ff71f5915e6012506efcc8f0dcd 100644 (file)
@@ -64,9 +64,8 @@ Tracking::~Tracking()
                state = DONE;
 // Not working in NPTL for some reason
 //             Thread::cancel();
-               Thread::join();
        }
-
+       Thread::join();
 
        delete startup_lock;
 }
index e3c468128907133bddb72d1123b48b29011dbb17..1213f5545ebf9c02850a529695e5e2d9e56228d7 100644 (file)
@@ -79,8 +79,8 @@ VDeviceBUZInput::~VDeviceBUZInput()
        {
                done = 1;
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
 
        if(buffer)
        {
index 76179b3be12e50bf3cedbdd1d3415ed1a1614a1a..ac640a20e4c550851ea83d40405fd6189ff3cfb2 100644 (file)
@@ -45,8 +45,8 @@ VideoWindow::~VideoWindow()
 {
        if(gui && running()) {
                gui->set_done(0);
-               join();
        }
+       join();
        delete gui;  gui = 0;
 }
 
index 704372187fa62eb3db165f82ca512fe84764b088..c91c51fe6b9182ffe7735250014d623426721877 100644 (file)
@@ -90,7 +90,7 @@ int BC_Clipboard::stop_clipboard()
 #endif
 // Must use a different display handle to send events.
        Display *display = BC_WindowBase::init_display(display_name);
-       XEvent event;
+       XEvent event;  memset(&event, 0, sizeof(event));
        XClientMessageEvent *ptr = (XClientMessageEvent*)&event;
 
        event.type = ClientMessage;
@@ -175,7 +175,7 @@ void BC_Clipboard::handle_selectionrequest(XSelectionRequestEvent *request)
        else if (request->target == targets_atom)
                success = handle_request_targets(request);
 
-       XEvent reply;
+       XEvent reply;  memset(&reply, 0, sizeof(reply));
 // 'None' tells the client that the request was denied
        reply.xselection.property  = success ? request->property : None;
        reply.xselection.type      = SelectionNotify;
index 16a38c4f0014441289155bfccb7566b0daa981e4..b7ec98e23265428484b901100e91d52d3e4c3d36 100644 (file)
@@ -46,6 +46,7 @@ BC_DragWindow::BC_DragWindow(BC_WindowBase *parent_window,
        pixmap)
 {
        temp_frame = 0;
+       drag_pixmap = 0;
 //     init_x = icon_x;
 //     init_y = icon_y;
        init_x = parent_window->get_abs_cursor_x(0) + DRAG_OFFSET_X;
@@ -90,6 +91,7 @@ BC_DragWindow::BC_DragWindow(BC_WindowBase *parent_window,
 
 BC_DragWindow::~BC_DragWindow()
 {
+       delete drag_pixmap;
 }
 
 int BC_DragWindow::get_init_x(BC_WindowBase *parent_window, int icon_x)
@@ -202,11 +204,11 @@ BC_Pixmap *BC_DragWindow::prepare_frame(VFrame *frame, BC_WindowBase *parent_win
                        0, frame->get_w(), temp_frame->get_w());
        }
        temp_frame->get_rows()[(temp_frame->get_h() / 2)][(temp_frame->get_w() / 2) * 4 + 3] = 0;
-       my_pixmap = new BC_Pixmap(parent_window,
+       drag_pixmap = new BC_Pixmap(parent_window,
                        temp_frame,
                        PIXMAP_ALPHA);
 
-       return (my_pixmap);
+       return drag_pixmap;
 }
 
 
index 2d9288fc94854692e0bff13488984e684d504536..c3b7c6e6963492b667eee2d36e899f06d6da470b 100644 (file)
@@ -48,7 +48,7 @@ private:
        int icon_offset_x, icon_offset_y;
        int do_animation;
        VFrame *temp_frame;
-       BC_Pixmap *my_pixmap;
+       BC_Pixmap *drag_pixmap;
 };
 
 #endif
index b48847ba14971e5315479764a856a48573531008..c78af1a68db7e489ea9cc9ecd1b838d68f97a251 100644 (file)
@@ -389,13 +389,9 @@ BC_ListBox::BC_ListBox(int x,
        popup_w = w;
        popup_h = h;
 
-       for(int i = 0; i < 3; i++)
-       {
-               button_images[i] = 0;
-               column_bg[i] = 0;
-       }
-       for(int i = 0; i < 5; i++)
-               toggle_images[i] = 0;
+       for(int i = 0; i < 3; i++) column_bg[i] = 0;
+       for(int i = 0; i < 4; i++) button_images[i] = 0;
+       for(int i = 0; i < 5; i++) toggle_images[i] = 0;
 
        column_sort_up = 0;
        column_sort_dn = 0;
@@ -447,13 +443,9 @@ BC_ListBox::~BC_ListBox()
        if(bg_pixmap) delete bg_pixmap;
        if(xscrollbar) delete xscrollbar;
        if(yscrollbar) delete yscrollbar;
-       for(int i = 0; i < 3; i++)
-       {
-               if(button_images[i]) delete button_images[i];
-               if(column_bg[i]) delete column_bg[i];
-       }
-       for(int i = 0; i < 5; i++)
-               if(toggle_images[i]) delete toggle_images[i];
+       for(int i = 0; i < 3; i++) delete column_bg[i];
+       for(int i = 0; i < 4; i++) delete button_images[i];
+       for(int i = 0; i < 5; i++) delete toggle_images[i];
        if(column_sort_up) delete column_sort_up;
        if(column_sort_dn) delete column_sort_dn;
 
@@ -550,7 +542,7 @@ int BC_ListBox::initialize()
        {
                if(use_button)
                {
-                       for( volatile int i = 0; i < 4; ++i ) // volatile due to cplr bug
+                       for( int i = 0; i < 4; ++i )
                        {
                                button_images[i] = new BC_Pixmap(parent_window,
                                        BC_WindowBase::get_resources()->listbox_button[i],
index 8100adfdd25c1a6fd3e513d744af680a917c906c..73c5ddb3a4805296ce795d36b9e0d9af709e5888 100644 (file)
@@ -534,7 +534,7 @@ private:
 
 
 // Popup button
-       BC_Pixmap *button_images[3];
+       BC_Pixmap *button_images[4];
 // Expander
        BC_Pixmap *toggle_images[5];
 // Background for drawing on
index 69cc52b16c58e384daf6a587f8b0c566f19902a4..ac49c98ac218a4eb027ba602850a9b25450580f6 100644 (file)
@@ -97,8 +97,8 @@ int BC_ProgressBox::stop_progress()
 {
        if( Thread::running() ) {
                pwindow->set_done(0);
-               Thread::join();
        }
+       Thread::join();
        return 0;
 }
 
index 35d4a1c1b03abe6c60c14f95c4edb8b6e43ca488..54f5eec2c5ca500e675ef58fb150845abaf9effc 100644 (file)
@@ -119,8 +119,8 @@ BC_Synchronous::~BC_Synchronous()
 {
        if( running() ) {
                quit();
-               join();
        }
+       join();
        commands.remove_all_objects();
        delete lock_sync;
        delete next_command;
index 389670c338e4dbff8843842cc7a5255589fb8a93..67226174a93a34ddf2f8514ad3f0ffba04b5fc90 100644 (file)
@@ -101,15 +101,20 @@ BC_WindowBase::~BC_WindowBase()
 #endif
 
 #ifdef HAVE_LIBXXF86VM
-   if(window_type == VIDMODE_SCALED_WINDOW && vm_switched)
-   {
-          restore_vm();
-   }
+       if(window_type == VIDMODE_SCALED_WINDOW && vm_switched) {
+               restore_vm();
+       }
 #endif
+       is_deleting = 1;
 
        hide_tooltip();
        if(window_type != MAIN_WINDOW)
        {
+// stop event input
+               XSelectInput(top_level->display, this->win, 0);
+               motion_events = resize_events = translation_events = 0;
+               top_level->dequeue_events(win);
+
                if(top_level->active_menubar == this) top_level->active_menubar = 0;
                if(top_level->active_popup_menu == this) top_level->active_popup_menu = 0;
                if(top_level->active_subwindow == this) top_level->active_subwindow = 0;
@@ -118,10 +123,10 @@ BC_WindowBase::~BC_WindowBase()
        }
 
        if(icon_window) delete icon_window;
-       if(window_type == POPUP_WINDOW) parent_window->remove_popup(this);
+       if(window_type == POPUP_WINDOW)
+               parent_window->remove_popup(this);
 
 // Delete the subwindows
-       is_deleting = 1;
        if(subwindows)
        {
                while(subwindows->total)
@@ -338,6 +343,7 @@ int BC_WindowBase::initialize()
        glx_win = 0;
 #endif
 
+       win = 0;
        return 0;
 }
 
@@ -1962,12 +1968,9 @@ Atom BC_WindowBase::create_xatom(const char *atom_name)
 
 int BC_WindowBase::get_atoms()
 {
-       SetDoneXAtom =  create_xatom("BC_REPEAT_EVENT");
-       RepeaterXAtom = create_xatom("BC_CLOSE_EVENT");
-       DelWinXAtom = create_xatom("WM_DELETE_WINDOW");
-       ProtoXAtom = create_xatom("WM_PROTOCOLS");
        SetDoneXAtom =  XInternAtom(display, "BC_REPEAT_EVENT", False);
        RepeaterXAtom = XInternAtom(display, "BC_CLOSE_EVENT", False);
+       DestroyAtom =   XInternAtom(display, "BC_DESTROY_WINDOW", False);
        DelWinXAtom =   XInternAtom(display, "WM_DELETE_WINDOW", False);
        if( (ProtoXAtom = XInternAtom(display, "WM_PROTOCOLS", False)) != 0 )
                XChangeProperty(display, win, ProtoXAtom, XA_ATOM, 32,
@@ -4351,6 +4354,20 @@ void BC_WindowBase::put_event(XEvent *event)
        event_condition->unlock();
 }
 
+void BC_WindowBase::dequeue_events(Window win)
+{
+       event_lock->lock("BC_WindowBase::dequeue_events");
+
+       int out = 0, total = common_events.size();
+       for( int in=0; in<total; ++in ) {
+               if( common_events[in]->xany.window == win ) continue;
+               common_events[out++] = common_events[in];
+       }
+       common_events.total = out;
+
+       event_lock->unlock();
+}
+
 #endif // SINGLE_THREAD
 
 int BC_WindowBase::get_id()
index af271e49bf82103c6391ecfafe376eae8c140419..4d0e45679bfc9b3fd436849f19c657de301c23bc 100644 (file)
@@ -581,6 +581,8 @@ private:
        int get_event_count();
 // Put event in common events.
        void put_event(XEvent *event);
+// remove events queued for win
+       void dequeue_events(Window win);
 
 // Recursive event dispatchers
        int dispatch_resize_event(int w, int h);
@@ -785,6 +787,7 @@ private:
 // Depth given by the X Server
        int default_depth;
        Atom DelWinXAtom;
+       Atom DestroyAtom;
        Atom ProtoXAtom;
        Atom RepeaterXAtom;
        Atom SetDoneXAtom;
index 3d4dd5b4c5d8f660f8b20eb0301215e402a0786f..2660c9498fa8a0f3604c849c1cf8599ea76cd912 100644 (file)
@@ -46,19 +46,16 @@ BC_WindowEvents::BC_WindowEvents(BC_Display *display)
 
 BC_WindowEvents::~BC_WindowEvents()
 {
-// First set done, then send dummy event through XSendEvent to unlock the loop in ::run()
+// no more external events, send one last event into X to flush out all of the
+//  pending events so that no straglers or shm leaks are possible.
 //printf("BC_WindowEvents::~BC_WindowEvents %d %s\n", __LINE__, window->title);
-       done = 1;
-       XEvent event;
+       XSelectInput(window->display, window->win, 0);
+       XEvent event;  memset(&event,0,sizeof(event));
        XClientMessageEvent *ptr = (XClientMessageEvent*)&event;
        event.type = ClientMessage;
-       ptr->message_type = XInternAtom(window->display, "DUMMY_XATOM", False);
+       ptr->message_type = window->DestroyAtom;
        ptr->format = 32;
-       XSendEvent(window->display,
-               window->win,
-               0,
-               0,
-               &event);
+       XSendEvent(window->display, window->win, 0, 0, &event);
        window->flush();
        Thread::join();
 //printf("BC_WindowEvents::~BC_WindowEvents %d %s\n", __LINE__, window->title);
@@ -80,8 +77,6 @@ void BC_WindowEvents::run()
        int x_fd = ConnectionNumber(window->display);
 #endif
 
-
-
        while(!done)
        {
 
@@ -90,7 +85,6 @@ void BC_WindowEvents::run()
 #ifdef SINGLE_THREAD
                event = new XEvent;
                XNextEvent(display->display, event);
-               display->put_event(event);
 #else
 // This came from a linuxquestions post.
 // We can get a file descriptor for the X display & use select instead of XNextEvent.  
@@ -107,20 +101,33 @@ void BC_WindowEvents::run()
                {
                        event = new XEvent;
                        XNextEvent(window->display, event);
+#endif
                        if( event->type == BC_WindowBase::shm_completion_event ) {
-                               window->top_level->active_bitmaps.reque(event);
+                               window->active_bitmaps.reque(event);
                                delete event;
                                continue;
                        }
+                       if( event->type == ClientMessage ) {
+                               XClientMessageEvent *ptr = (XClientMessageEvent*)event;
+                               if( ptr->message_type == window->DestroyAtom ) {
+                                       delete event;
+                                       done = 1;
+                                       break;
+                               }
+                       }
+#ifndef SINGLE_THREAD
 // HACK: delay is required to get the close event
-                       usleep(1);
+                       yield();
 //if(window && event)
 //printf("BC_WindowEvents::run %d %s %d\n", __LINE__, window->title, event->type);
                        window->put_event(event);
                }
                XUnlockDisplay(window->display);
 //printf("BC_WindowEvents::run %d %s\n", __LINE__, window->title);
+#else
+               display->put_event(event);
 #endif
+
        }
 }
 
index 2a2029edf138fd548dd811d91d5e19e9b8a50bf3..31ab44a1fcd626453374a1b3d0e3bd29af8714f1 100644 (file)
@@ -408,8 +408,8 @@ RotateEngine::~RotateEngine()
        {
                done = 1;
                input_lock->unlock();
-               join();
        }
+       join();
        delete input_lock;
        delete output_lock;
 }
index 906fb6e938556377af762768e82dd8cd9428a823..deb3c57fd6370b1aa7af9b7d54ca4c88b8c01b9c 100644 (file)
@@ -87,8 +87,8 @@ VIconThread::
        draw_lock->unlock();
        if( Thread::running() ) {
                Thread::cancel();
-               Thread::join();
        }
+       Thread::join();
        t_heap.remove_all_objects();
        delete timer;
        delete draw_lock;