aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/c_src/wxe_impl.cpp
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2015-05-12 09:22:20 +0200
committerDan Gudmundsson <[email protected]>2015-05-12 09:22:20 +0200
commit62b24429f440c61ad930d919e49ec637d3580096 (patch)
treea5164b14f3b5608e19268b7a06b322685295ead4 /lib/wx/c_src/wxe_impl.cpp
parentccb1a2f06aa2b0ab77447572797d7fd75b2bd3c4 (diff)
downloadotp-62b24429f440c61ad930d919e49ec637d3580096.tar.gz
otp-62b24429f440c61ad930d919e49ec637d3580096.tar.bz2
otp-62b24429f440c61ad930d919e49ec637d3580096.zip
wx: Fix raise during emulator stoppage
When emulator is stopped all drivers are stopped but not unloaded and since the clean wx thread stoppage code was in unload callback it was not called and could cause crashes.
Diffstat (limited to 'lib/wx/c_src/wxe_impl.cpp')
-rw-r--r--lib/wx/c_src/wxe_impl.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp
index ef648e008c..2fd5f0c52c 100644
--- a/lib/wx/c_src/wxe_impl.cpp
+++ b/lib/wx/c_src/wxe_impl.cpp
@@ -89,7 +89,7 @@ void push_command(int op,char * buf,int len, wxe_data *sd)
}
void meta_command(int what, wxe_data *sd) {
- if(what == PING_PORT) {
+ if(what == PING_PORT && wxe_status == WXE_INITIATED) {
erl_drv_mutex_lock(wxe_batch_locker_m);
if(wxe_batch_caller > 0) {
wxe_queue->Add(WXE_DEBUG_PING, NULL, 0, sd);
@@ -98,9 +98,12 @@ void meta_command(int what, wxe_data *sd) {
wxWakeUpIdle();
erl_drv_mutex_unlock(wxe_batch_locker_m);
} else {
- if(sd) {
+ if(sd && wxe_status == WXE_INITIATED) {
wxeMetaCommand Cmd(sd, what);
wxTheApp->AddPendingEvent(Cmd);
+ if(what == DELETE_PORT) {
+ free(sd);
+ }
}
}
}
@@ -169,6 +172,7 @@ void WxeApp::MacOpenFile(const wxString &filename) {
#endif
void WxeApp::shutdown(wxeMetaCommand& Ecmd) {
+ wxe_status = WXE_EXITING;
ExitMainLoop();
delete wxe_queue;
delete wxe_queue_cb_saved;
@@ -200,6 +204,10 @@ void handle_event_callback(ErlDrvPort port, ErlDrvTermData process)
{
WxeApp * app = (WxeApp *) wxTheApp;
ErlDrvMonitor monitor;
+
+ if(wxe_status != WXE_INITIATED)
+ return;
+
// Is thread safe if pdl have been incremented
if(driver_monitor_process(port, process, &monitor) == 0) {
// Should we be able to handle commands when recursing? probably
@@ -217,6 +225,8 @@ void handle_event_callback(ErlDrvPort port, ErlDrvTermData process)
void WxeApp::dispatch_cmds()
{
+ if(wxe_status != WXE_INITIATED)
+ return;
erl_drv_mutex_lock(wxe_batch_locker_m);
recurse_level++;
int level = dispatch(wxe_queue_cb_saved, 0, WXE_STORED);