if( Thread::running() ) {
done = 1;
Thread::cancel();
- Thread::join();
}
+ Thread::join();
}
dwindow->lock_window("DetailAssetThread::stop");
dwindow->set_done(1);
dwindow->unlock_window();
- Thread::join();
}
+ Thread::join();
}
void DetailAssetWindow::create_objects()
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;
{
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;
if( !interrupt ) {
// Cancel previous job
interrupt = 1;
- Thread::join();
}
+ Thread::join();
if( progress ) {
progress->stop_progress();
delete progress; progress = 0;
if( gui ) gui->set_done(1);
window_lock->unlock();
Thread::cancel();
- Thread::join();
}
+ Thread::join();
}
void ChanSearch::run()
if( Thread::running() ) {
done = 1;
Thread::cancel();
- Thread::join();
}
+ Thread::join();
}
void ChannelProgress::run()
if( Thread::running() ) {
done = 1;
Thread::cancel();
- Thread::join();
}
+ Thread::join();
}
ChannelThread::ChannelThread(ChannelInfoGUI *gui)
if( gui ) gui->stop(1);
window_lock->unlock();
Thread::cancel();
- Thread::join();
}
+ Thread::join();
}
void ChannelInfo::run()
if( running() ) {
if( gui ) gui->set_done(1);
cancel();
- join();
}
+ join();
}
void ScanStatus::
done = 1;
input_lock->unlock();
cancel();
- join();
}
+ join();
if( commercials && !commercials->remove_user() )
commercials = 0;
}
{
if(gui && running()) {
gui->set_done(0);
- join();
}
+ join();
delete gui; gui = 0;
delete playback_engine;
delete playback_cursor;
if( gui ) gui->set_done(1);
window_lock->unlock();
Thread::cancel();
- Thread::join();
}
+ Thread::join();
}
void DbWindow::
{
done = 1;
Thread::cancel();
- Thread::join();
}
+ Thread::join();
if(buffer)
{
done = 1;
start_lock->unlock();
Thread::cancel();
- Thread::join();
}
+ Thread::join();
if(buffer)
{
done = 1;
buffer_lock->unlock();
Thread::cancel();
- Thread::join();
}
+ Thread::join();
delete buffer_lock;
delete putq;
}
{
done = 1;
Thread::cancel();
- Thread::join();
}
+ Thread::join();
if(put_thread)
{
delete put_thread;
{
done = 1;
Thread::cancel();
- Thread::join();
}
+ Thread::join();
if(fd > 0) close(fd);
}
if( running() ) {
done = 1;
mux_lock->unlock();
- join();
}
+ join();
}
void FFMPEG::flow_off()
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);
}
{
done = 1;
read_wait_lock->unlock();
- Thread::join();
}
+ Thread::join();
return 0;
}
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();
}
}
{
if(gui && running()) {
gui->set_done(0);
- join();
}
+ join();
delete gui; gui = 0;
}
if(Thread::running())
{
done = 1;
- Thread::join();
}
+ Thread::join();
if(buffer)
{
done = 1;
start_lock->unlock();
Thread::cancel();
- Thread::join();
}
+ Thread::join();
if(buffer)
{
{
if(gui && running()) {
gui->set_done(0);
- join();
}
+ join();
delete gui; gui = 0;
}
mwindow->mainindexes->add_next_asset(0, nested_edl);
}
mwindow->mainindexes->start_build();
+ mwindow->update_plugin_guis(1);
return 0;
}
int MWindow::interrupt_indexes()
{
+ mainprogress->cancelled = 1;
mainindexes->interrupt_build();
return 0;
}
PluginFClient::~PluginFClient()
{
+ delete ffilt;
}
bool PluginFClient::is_audio(AVFilter *fp)
window->lock_window("EndRecordThread::~EndRecordThread");
window->set_done(1);
window->unlock_window();
- Thread::join();
}
+ Thread::join();
}
void EndRecordThread::start(int is_ok)
window->lock_window("RecordStartoverThread::~RecordStartoverThread");
window->set_done(1);
window->unlock_window();
- Thread::join();
}
+ Thread::join();
}
void RecordStartoverThread::run()
{
done = 1;
input_lock->unlock();
- Thread::join();
}
+ Thread::join();
}
void RecordStatusThread::reset_video()
done = 1;
flash_lock->unlock();
Thread::cancel();
- Thread::join();
}
+ Thread::join();
delete flash_lock;
}
{
if( Thread::running() ) {
remote_window->close(1);
- Thread::join();
}
+ Thread::join();
delete gui;
delete remote_window;
delete active_lock;
done = 1;
interrupted = 1;
draw_lock->unlock();
- join();
}
+ join();
}
if( running() ) {
window->set_done(1);
cancel();
- join();
}
+ join();
delete window_lock;
}
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);
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 )
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;
if( gui ) gui->stop(1);
window_lock->unlock();
Thread::cancel();
- Thread::join();
}
+ Thread::join();
}
void SWindow::run()
state = DONE;
// Not working in NPTL for some reason
// Thread::cancel();
- Thread::join();
}
-
+ Thread::join();
delete startup_lock;
}
{
done = 1;
Thread::cancel();
- Thread::join();
}
+ Thread::join();
if(buffer)
{
{
if(gui && running()) {
gui->set_done(0);
- join();
}
+ join();
delete gui; gui = 0;
}
#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;
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;
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;
BC_DragWindow::~BC_DragWindow()
{
+ delete drag_pixmap;
}
int BC_DragWindow::get_init_x(BC_WindowBase *parent_window, int icon_x)
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;
}
int icon_offset_x, icon_offset_y;
int do_animation;
VFrame *temp_frame;
- BC_Pixmap *my_pixmap;
+ BC_Pixmap *drag_pixmap;
};
#endif
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;
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;
{
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],
// Popup button
- BC_Pixmap *button_images[3];
+ BC_Pixmap *button_images[4];
// Expander
BC_Pixmap *toggle_images[5];
// Background for drawing on
{
if( Thread::running() ) {
pwindow->set_done(0);
- Thread::join();
}
+ Thread::join();
return 0;
}
{
if( running() ) {
quit();
- join();
}
+ join();
commands.remove_all_objects();
delete lock_sync;
delete next_command;
#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;
}
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)
glx_win = 0;
#endif
+ win = 0;
return 0;
}
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,
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()
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);
// Depth given by the X Server
int default_depth;
Atom DelWinXAtom;
+ Atom DestroyAtom;
Atom ProtoXAtom;
Atom RepeaterXAtom;
Atom SetDoneXAtom;
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);
int x_fd = ConnectionNumber(window->display);
#endif
-
-
while(!done)
{
#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.
{
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
+
}
}
{
done = 1;
input_lock->unlock();
- join();
}
+ join();
delete input_lock;
delete output_lock;
}
draw_lock->unlock();
if( Thread::running() ) {
Thread::cancel();
- Thread::join();
}
+ Thread::join();
t_heap.remove_all_objects();
delete timer;
delete draw_lock;