r419: various fixes, memory allocations, etc.
[cinelerra_cv/mob.git] / guicast / bcdialog.C
blob13d53953aa95f24d71f20768517c6a5e301afdc7
1 #include "bcdialog.h"
2 #include "mutex.h"
8 BC_DialogThread::BC_DialogThread()
9  : Thread(1, 0, 0)
11         gui = 0;
12         startup_lock = new Mutex("BC_DialogThread::startup_lock");
13         window_lock = new Mutex("BC_DialogThread::window_lock");
16 BC_DialogThread::~BC_DialogThread()
18         startup_lock->lock("BC_DialogThread::~BC_DialogThread");
19         if(gui)
20         {
21                 gui->lock_window();
22                 gui->set_done(1);
23                 gui->unlock_window();
24         }
25         startup_lock->unlock();
26         Thread::join();
28         delete startup_lock;
29         delete window_lock;
32 void BC_DialogThread::start()
34         if(Thread::running())
35         {
36                 window_lock->lock("BC_DialogThread::start");
37                 if(gui)
38                 {
39                         gui->lock_window("BC_DialogThread::start");
40                         gui->raise_window(1);
41                         gui->unlock_window();
42                 }
43                 window_lock->unlock();
44                 return;
45         }
47 // Don't allow anyone else to create the window
48         startup_lock->lock("BC_DialogThread::start");
49         Thread::start();
51 // Wait for startup
52         startup_lock->lock("BC_DialogThread::start");
53         startup_lock->unlock();
56 void BC_DialogThread::run()
58         gui = new_gui();
59         startup_lock->unlock();
60         int result = gui->run_window();
62         window_lock->lock("BC_DialogThread::run");
63         delete gui;
64         gui = 0;
65         window_lock->unlock();
67         handle_close_event(result);
70 BC_Window* BC_DialogThread::new_gui()
72         printf("BC_DialogThread::new_gui called\n");
73         return 0;
76 void BC_DialogThread::handle_close_event(int result)