aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/api_gen
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2013-12-20 09:20:22 +0100
committerDan Gudmundsson <[email protected]>2014-01-14 13:26:53 +0100
commit74f6d6d74f7a3be5aece37a0b419e40d96e036d4 (patch)
tree73ffc54f3b8b9b827f6f2a9aedd46b566dce7ffa /lib/wx/api_gen
parent3f9b80b1e635f3b5f39bd7380b3bd777ebd98338 (diff)
downloadotp-74f6d6d74f7a3be5aece37a0b419e40d96e036d4.tar.gz
otp-74f6d6d74f7a3be5aece37a0b419e40d96e036d4.tar.bz2
otp-74f6d6d74f7a3be5aece37a0b419e40d96e036d4.zip
wx: Fix crash when garbage collect event handlers (debugger caused seg fault)
wxStyledTextCtrl had no wrapper class so, because it was not detected that it had virtual destructors, thus references to it was not cleaned up on destruction. When a process dies and wx cleans up the event handlers access was made to the deleted object and caused a seg fault. Added a testcase which I thought could provoke the bug but didn't.
Diffstat (limited to 'lib/wx/api_gen')
-rw-r--r--lib/wx/api_gen/wx_gen_cpp.erl34
1 files changed, 12 insertions, 22 deletions
diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl
index 7e35ebfa83..6eed0668f6 100644
--- a/lib/wx/api_gen/wx_gen_cpp.erl
+++ b/lib/wx/api_gen/wx_gen_cpp.erl
@@ -855,34 +855,24 @@ call_arg(#param{name=N,type={merged,_,_,_,_,_,_}}) -> N.
to_string(Type) when is_atom(Type) -> atom_to_list(Type);
to_string(Type) when is_list(Type) -> Type.
-virtual_dest(#class{abstract=true, parent="root"}) -> false;
-virtual_dest(#class{abstract=true, parent="object"}) -> true;
virtual_dest(#class{abstract=true, parent=Parent}) ->
- virtual_dest(get({class,Parent}));
+ virtual_dest(get_parent_class(Parent));
virtual_dest(#class{methods=Ms, parent=Parent}) ->
case lists:keysearch(destructor,#method.method_type, lists:append(Ms)) of
{value, #method{method_type=destructor, virtual=Virtual}} ->
case Virtual of
- undefined ->
- case get({class,Parent}) of
- undefined ->
- case Parent of
- "object" ->
- true;
- "root" ->
- false;
- _ ->
- io:format("Error: ~p~n",[Parent]),
- erlang:error(no_parent)
- end;
- PClass ->
- virtual_dest(PClass)
- end;
- _ ->
- Virtual
+ true -> true;
+ _ -> virtual_dest(get_parent_class(Parent))
end;
- false ->
- false
+ false -> virtual_dest(get_parent_class(Parent))
+ end;
+virtual_dest("root") -> false;
+virtual_dest("object") -> true.
+
+get_parent_class(Parent) ->
+ case get({class, Parent}) of
+ undefined -> Parent;
+ Class -> Class
end.
debug(F,A) ->