aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/api_gen
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2014-05-22 13:46:53 +0200
committerDan Gudmundsson <[email protected]>2014-06-16 12:10:48 +0200
commit190c04f50ab22e0227a0d5cfd67767db0b687c97 (patch)
tree0cbf50113363b927545d4d931961f3261893850f /lib/wx/api_gen
parentb146f66ea96bacca6915f7e3b29ac7dcebd93119 (diff)
downloadotp-190c04f50ab22e0227a0d5cfd67767db0b687c97.tar.gz
otp-190c04f50ab22e0227a0d5cfd67767db0b687c97.tar.bz2
otp-190c04f50ab22e0227a0d5cfd67767db0b687c97.zip
wx: Fix destroy bug
Do not postpone deletion of wx*DC objects since they need to be deleted directly. Otherwise, if inside showModal, causes an eternal loop of wxPaint events on Windows.
Diffstat (limited to 'lib/wx/api_gen')
-rw-r--r--lib/wx/api_gen/wx_gen_cpp.erl25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl
index 72fcce43d4..107d064f4a 100644
--- a/lib/wx/api_gen/wx_gen_cpp.erl
+++ b/lib/wx/api_gen/wx_gen_cpp.erl
@@ -191,13 +191,14 @@ gen_funcs(Defs) ->
%% w(" case WXE_REMOVE_PORT:~n", []),
%% w(" { destroyMemEnv(Ecmd.port); } break;~n", []),
w(" case DESTROY_OBJECT: {~n"),
- w(" wxObject *This = (wxObject *) getPtr(bp,memenv);~n"),
- w(" if(This) {~n"),
- w(" if(recurse_level > 1) {~n"),
+ w(" void *This = getPtr(bp,memenv);~n"),
+ w(" wxeRefData *refd = getRefData(This);~n"),
+ w(" if(This && refd) {~n"),
+ w(" if(recurse_level > 1 && refd->type != 4) {~n"),
w(" delayed_delete->Append(Ecmd.Save());~n"),
w(" } else {~n"),
- w(" ((WxeApp *) wxTheApp)->clearPtr((void *) This);~n"),
- w(" delete This; }~n"),
+ w(" ((WxeApp *) wxTheApp)->clearPtr(This);~n"),
+ w(" delete_object(This, refd); }~n"),
w(" } } break;~n"),
w(" case WXE_REGISTER_OBJECT: {~n"
" registerPid(bp, Ecmd.caller, memenv);~n"
@@ -737,9 +738,13 @@ call_wx(_N,{constructor,_},#type{base={class,RClass}},Ps) ->
false -> 0
end;
false ->
- case hd(reverse(wx_gen_erl:parents(RClass))) of
- root -> Id;
- _ -> 1
+ case is_dc(RClass) of
+ true -> 4;
+ false ->
+ case hd(reverse(wx_gen_erl:parents(RClass))) of
+ root -> Id;
+ _ -> 1
+ end
end
end,
case virtual_dest(ClassDef) orelse (CType =/= 0) of
@@ -901,6 +906,10 @@ is_window(Class) ->
is_dialog(Class) ->
lists:member("wxDialog", wx_gen_erl:parents(Class)).
+is_dc(Class) ->
+ Parents = wx_gen_erl:parents(Class),
+ lists:member("wxDC", Parents) orelse lists:member("wxGraphicsContext", Parents).
+
build_return_vals(Type,Ps) ->
HaveType = case Type of void -> 0; _ -> 1 end,
NoOut = lists:sum([1 || #param{in=In} <- Ps, In =/= true]) + HaveType,