diff options
author | Dan Gudmundsson <[email protected]> | 2016-05-31 09:15:05 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2016-05-31 09:15:05 +0200 |
commit | ffd39bdee7d0cbac044ca6c72afb65689c33b168 (patch) | |
tree | 1426bffdff4216370a35e07ded62839de9568cfa | |
parent | 492b0ac2e3305a37ab507b2ff2d9546456cf61e4 (diff) | |
parent | b304be8094f283001d6dfbafab31ead37c585869 (diff) | |
download | otp-ffd39bdee7d0cbac044ca6c72afb65689c33b168.tar.gz otp-ffd39bdee7d0cbac044ca6c72afb65689c33b168.tar.bz2 otp-ffd39bdee7d0cbac044ca6c72afb65689c33b168.zip |
Merge branch 'dgud/wx/fix-seqfault-in-cleanup'
* dgud/wx/fix-seqfault-in-cleanup:
wx: Fix occasional seq fault after appliction stops
-rw-r--r-- | lib/wx/api_gen/wx_gen_cpp.erl | 40 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_erl.erl | 2 | ||||
-rw-r--r-- | lib/wx/c_src/gen/wxe_funcs.cpp | 81 | ||||
-rw-r--r-- | lib/wx/c_src/wxe_impl.cpp | 17 | ||||
-rw-r--r-- | lib/wx/c_src/wxe_memory.h | 5 | ||||
-rw-r--r-- | lib/wx/examples/demo/ex_graphicsContext.erl | 2 | ||||
-rw-r--r-- | lib/wx/src/gen/wxAcceleratorTable.erl | 2 |
7 files changed, 89 insertions, 60 deletions
diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl index 55c179142d..84d3990786 100644 --- a/lib/wx/api_gen/wx_gen_cpp.erl +++ b/lib/wx/api_gen/wx_gen_cpp.erl @@ -210,7 +210,7 @@ gen_funcs(Defs) -> 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(" if(recurse_level > 1 && refd->type != 8) {~n"), w(" delayed_delete->Append(Ecmd.Save(op));~n"), w(" } else {~n"), w(" delete_object(This, refd);~n"), @@ -255,7 +255,21 @@ gen_funcs(Defs) -> ], w("bool WxeApp::delete_object(void *ptr, wxeRefData *refd) {~n", []), + w(" if(wxe_debug) {\n" + " wxString msg;\n" + " const wxChar *class_info = wxT(\"unknown\");\n" + " if(refd->type < 10) {\n" + " wxClassInfo *cinfo = ((wxObject *)ptr)->GetClassInfo();\n" + " class_info = cinfo->GetClassName();\n" + " }\n" + " msg.Printf(wxT(\"Deleting {wx_ref, %d, %s} at %p \"), refd->ref, class_info, ptr);\n" + " send_msg(\"debug\", &msg);\n" + " };\n"), + w(" switch(refd->type) {~n", []), + w("#if wxUSE_GRAPHICS_CONTEXT~n", []), + w(" case 4: delete (wxGraphicsObject *) ptr; break;~n", []), + w("#endif~n", []), Case = fun(C=#class{name=Class, id=Id, abstract=IsAbs, parent=P}) when P /= "static" -> UglyWorkaround = lists:member(Class, UglySkipList), HaveVirtual = virtual_dest(C), @@ -761,7 +775,7 @@ call_wx(_N,{constructor,_},#type{base={class,RClass}},Ps) -> end; false -> case is_dc(RClass) of - true -> 4; + true -> 8; false -> case hd(reverse(wx_gen_erl:parents(RClass))) of root -> Id; @@ -819,19 +833,19 @@ return_res1(#type{name=Type,base={class,_},single=list,ref=reference}) -> return_res1(#type{name=Type,base={comp,_,_},single=array,by_val=true}) -> {Type ++ " Result = ", ""}; return_res1(#type{name=Type,single=true,by_val=true, base={class, _}}) -> - %% Temporary memory leak !!!!!! - case {need_copy_constr(Type),Type} of - {true, _} -> ok; - {_, "wxGraphics" ++ _} -> ok; - _ -> - io:format("~s::~s Building return value of temp ~s~n", - [get(current_class),get(current_func),Type]) - end, - case need_copy_constr(Type) of - true -> + case {need_copy_constr(Type), Type} of + {true, _} -> {Type ++ " * Result = new E" ++ Type ++ "(", "); newPtr((void *) Result," ++ "3, memenv);"}; - false -> + {false, "wxGraphics" ++ _} -> + %% {"wxGraphicsObject * Result = new wxGraphicsObject(", "); newPtr((void *) Result," + %% ++ "3, memenv);"}; + {Type ++ " * Result = new " ++ Type ++ "(", "); newPtr((void *) Result," + ++ "4, memenv);"}; + {false, _} -> + %% Temporary memory leak !!!!!! + io:format("~s::~s Building return value of temp ~s~n", + [get(current_class),get(current_func),Type]), {Type ++ " * Result = new " ++ Type ++ "(", "); newPtr((void *) Result," ++ "3, memenv);"} end; diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl index e15bb0b5ad..794de25002 100644 --- a/lib/wx/api_gen/wx_gen_erl.erl +++ b/lib/wx/api_gen/wx_gen_erl.erl @@ -482,7 +482,7 @@ arg_type_test(#param{name=Name0,in=In,type=#type{base={class,T},single=true},def arg_type_test(#param{name=Name0,in=In,type=#type{base={class,T}}, def=none},EOS,Acc) when In =/= false -> Name = erl_arg_name(Name0), - w(" [?CLASS(~sT,~s) || #wx_ref{type=~sT} <- ~s],~s", [Name,T,Name,Name,EOS]), + w(" _ = [?CLASS(~sT,~s) || #wx_ref{type=~sT} <- ~s],~s", [Name,T,Name,Name,EOS]), Acc; arg_type_test(#param{name=Name0,def=none,in=In, type={merged, diff --git a/lib/wx/c_src/gen/wxe_funcs.cpp b/lib/wx/c_src/gen/wxe_funcs.cpp index 942baf7c7f..4243d8a35a 100644 --- a/lib/wx/c_src/gen/wxe_funcs.cpp +++ b/lib/wx/c_src/gen/wxe_funcs.cpp @@ -51,7 +51,7 @@ void WxeApp::wxe_dispatch(wxeCommand& Ecmd) void *This = getPtr(bp,memenv); wxeRefData *refd = getRefData(This); if(This && refd) { - if(recurse_level > 1 && refd->type != 4) { + if(recurse_level > 1 && refd->type != 8) { delayed_delete->Append(Ecmd.Save(op)); } else { delete_object(This, refd); @@ -5889,27 +5889,27 @@ case wxMirrorDC_new: { // wxMirrorDC::wxMirrorDC wxDC *dc = (wxDC *) getPtr(bp,memenv); bp += 4; bool * mirror = (bool *) bp; bp += 4; wxMirrorDC * Result = new EwxMirrorDC(*dc,*mirror); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxMirrorDC"); break; } case wxScreenDC_new: { // wxScreenDC::wxScreenDC wxScreenDC * Result = new EwxScreenDC(); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxScreenDC"); break; } #if wxUSE_POSTSCRIPT case wxPostScriptDC_new_0: { // wxPostScriptDC::wxPostScriptDC wxPostScriptDC * Result = new EwxPostScriptDC(); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxPostScriptDC"); break; } case wxPostScriptDC_new_1: { // wxPostScriptDC::wxPostScriptDC wxPrintData *printData = (wxPrintData *) getPtr(bp,memenv); bp += 4; wxPostScriptDC * Result = new EwxPostScriptDC(*printData); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxPostScriptDC"); break; } @@ -5931,7 +5931,7 @@ case wxPostScriptDC_GetResolution: { // wxPostScriptDC::GetResolution #if !wxCHECK_VERSION(2,9,0) case wxWindowDC_new_0: { // wxWindowDC::wxWindowDC wxWindowDC * Result = new EwxWindowDC(); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxWindowDC"); break; } @@ -5939,14 +5939,14 @@ case wxWindowDC_new_0: { // wxWindowDC::wxWindowDC case wxWindowDC_new_1: { // wxWindowDC::wxWindowDC wxWindow *win = (wxWindow *) getPtr(bp,memenv); bp += 4; wxWindowDC * Result = new EwxWindowDC(win); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxWindowDC"); break; } #if !wxCHECK_VERSION(2,9,0) case wxClientDC_new_0: { // wxClientDC::wxClientDC wxClientDC * Result = new EwxClientDC(); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxClientDC"); break; } @@ -5954,14 +5954,14 @@ case wxClientDC_new_0: { // wxClientDC::wxClientDC case wxClientDC_new_1: { // wxClientDC::wxClientDC wxWindow *win = (wxWindow *) getPtr(bp,memenv); bp += 4; wxClientDC * Result = new EwxClientDC(win); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxClientDC"); break; } #if !wxCHECK_VERSION(2,9,0) case wxPaintDC_new_0: { // wxPaintDC::wxPaintDC wxPaintDC * Result = new EwxPaintDC(); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxPaintDC"); break; } @@ -5969,27 +5969,27 @@ case wxPaintDC_new_0: { // wxPaintDC::wxPaintDC case wxPaintDC_new_1: { // wxPaintDC::wxPaintDC wxWindow *win = (wxWindow *) getPtr(bp,memenv); bp += 4; wxPaintDC * Result = new EwxPaintDC(win); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxPaintDC"); break; } case wxMemoryDC_new_1_0: { // wxMemoryDC::wxMemoryDC wxBitmap *bitmap = (wxBitmap *) getPtr(bp,memenv); bp += 4; wxMemoryDC * Result = new EwxMemoryDC(*bitmap); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxMemoryDC"); break; } case wxMemoryDC_new_1_1: { // wxMemoryDC::wxMemoryDC wxDC * dc = (wxDC *) getPtr(bp,memenv); bp += 4; wxMemoryDC * Result = new EwxMemoryDC(dc); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxMemoryDC"); break; } case wxMemoryDC_new_0: { // wxMemoryDC::wxMemoryDC wxMemoryDC * Result = new EwxMemoryDC(); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxMemoryDC"); break; } @@ -6009,7 +6009,7 @@ case wxMemoryDC_SelectObjectAsSource: { // wxMemoryDC::SelectObjectAsSource } case wxBufferedDC_new_0: { // wxBufferedDC::wxBufferedDC wxBufferedDC * Result = new EwxBufferedDC(); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxBufferedDC"); break; } @@ -6027,7 +6027,7 @@ buffer = (wxBitmap *) getPtr(bp,memenv); bp += 4; } break; }}; wxBufferedDC * Result = new EwxBufferedDC(dc,*buffer,style); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxBufferedDC"); break; } @@ -6044,7 +6044,7 @@ case wxBufferedDC_new_3: { // wxBufferedDC::wxBufferedDC } break; }}; wxBufferedDC * Result = new EwxBufferedDC(dc,area,style); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxBufferedDC"); break; } @@ -6091,7 +6091,7 @@ case wxBufferedPaintDC_new_3: { // wxBufferedPaintDC::wxBufferedPaintDC } break; }}; wxBufferedPaintDC * Result = new EwxBufferedPaintDC(window,*buffer,style); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxBufferedPaintDC"); break; } @@ -6105,7 +6105,7 @@ case wxBufferedPaintDC_new_2: { // wxBufferedPaintDC::wxBufferedPaintDC } break; }}; wxBufferedPaintDC * Result = new EwxBufferedPaintDC(window,style); - newPtr((void *) Result, 4, memenv); + newPtr((void *) Result, 8, memenv); rt.addRef(getRef((void *)Result,memenv), "wxBufferedPaintDC"); break; } @@ -6147,7 +6147,7 @@ case wxGraphicsContext_CreatePen: { // wxGraphicsContext::CreatePen wxGraphicsContext *This = (wxGraphicsContext *) getPtr(bp,memenv); bp += 4; wxPen *pen = (wxPen *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); - wxGraphicsPen * Result = new wxGraphicsPen(This->CreatePen(*pen)); newPtr((void *) Result,3, memenv);; + wxGraphicsPen * Result = new wxGraphicsPen(This->CreatePen(*pen)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsPen"); break; } @@ -6155,7 +6155,7 @@ case wxGraphicsContext_CreateBrush: { // wxGraphicsContext::CreateBrush wxGraphicsContext *This = (wxGraphicsContext *) getPtr(bp,memenv); bp += 4; wxBrush *brush = (wxBrush *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); - wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateBrush(*brush)); newPtr((void *) Result,3, memenv);; + wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateBrush(*brush)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsBrush"); break; } @@ -6179,7 +6179,7 @@ case wxGraphicsContext_CreateRadialGradientBrush: { // wxGraphicsContext::Create int * cColorA = (int *) bp; bp += 4; wxColour cColor = wxColour(*cColorR,*cColorG,*cColorB,*cColorA); if(!This) throw wxe_badarg(0); - wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateRadialGradientBrush(*xo,*yo,*xc,*yc,*radius,oColor,cColor)); newPtr((void *) Result,3, memenv);; + wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateRadialGradientBrush(*xo,*yo,*xc,*yc,*radius,oColor,cColor)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsBrush"); break; } @@ -6203,7 +6203,7 @@ case wxGraphicsContext_CreateLinearGradientBrush: { // wxGraphicsContext::Create int * c2A = (int *) bp; bp += 4; wxColour c2 = wxColour(*c2R,*c2G,*c2B,*c2A); if(!This) throw wxe_badarg(0); - wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateLinearGradientBrush(*x1,*y1,*x2,*y2,c1,c2)); newPtr((void *) Result,3, memenv);; + wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateLinearGradientBrush(*x1,*y1,*x2,*y2,c1,c2)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsBrush"); break; } @@ -6223,7 +6223,7 @@ case wxGraphicsContext_CreateFont: { // wxGraphicsContext::CreateFont } break; }}; if(!This) throw wxe_badarg(0); - wxGraphicsFont * Result = new wxGraphicsFont(This->CreateFont(*font,col)); newPtr((void *) Result,3, memenv);; + wxGraphicsFont * Result = new wxGraphicsFont(This->CreateFont(*font,col)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsFont"); break; } @@ -6263,14 +6263,14 @@ case wxGraphicsContext_CreateMatrix: { // wxGraphicsContext::CreateMatrix } break; }}; if(!This) throw wxe_badarg(0); - wxGraphicsMatrix * Result = new wxGraphicsMatrix(This->CreateMatrix(a,b,c,d,tx,ty)); newPtr((void *) Result,3, memenv);; + wxGraphicsMatrix * Result = new wxGraphicsMatrix(This->CreateMatrix(a,b,c,d,tx,ty)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsMatrix"); break; } case wxGraphicsContext_CreatePath: { // wxGraphicsContext::CreatePath wxGraphicsContext *This = (wxGraphicsContext *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); - wxGraphicsPath * Result = new wxGraphicsPath(This->CreatePath()); newPtr((void *) Result,3, memenv);; + wxGraphicsPath * Result = new wxGraphicsPath(This->CreatePath()); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsPath"); break; } @@ -6514,7 +6514,7 @@ case wxGraphicsContext_Translate: { // wxGraphicsContext::Translate case wxGraphicsContext_GetTransform: { // wxGraphicsContext::GetTransform wxGraphicsContext *This = (wxGraphicsContext *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); - wxGraphicsMatrix * Result = new wxGraphicsMatrix(This->GetTransform()); newPtr((void *) Result,3, memenv);; + wxGraphicsMatrix * Result = new wxGraphicsMatrix(This->GetTransform()); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsMatrix"); break; } @@ -7000,7 +7000,7 @@ case wxGraphicsRenderer_CreatePen: { // wxGraphicsRenderer::CreatePen wxGraphicsRenderer *This = (wxGraphicsRenderer *) getPtr(bp,memenv); bp += 4; wxPen *pen = (wxPen *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); - wxGraphicsPen * Result = new wxGraphicsPen(This->CreatePen(*pen)); newPtr((void *) Result,3, memenv);; + wxGraphicsPen * Result = new wxGraphicsPen(This->CreatePen(*pen)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsPen"); break; } @@ -7008,7 +7008,7 @@ case wxGraphicsRenderer_CreateBrush: { // wxGraphicsRenderer::CreateBrush wxGraphicsRenderer *This = (wxGraphicsRenderer *) getPtr(bp,memenv); bp += 4; wxBrush *brush = (wxBrush *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); - wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateBrush(*brush)); newPtr((void *) Result,3, memenv);; + wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateBrush(*brush)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsBrush"); break; } @@ -7031,7 +7031,7 @@ case wxGraphicsRenderer_CreateLinearGradientBrush: { // wxGraphicsRenderer::Crea int * c2A = (int *) bp; bp += 4; wxColour c2 = wxColour(*c2R,*c2G,*c2B,*c2A); if(!This) throw wxe_badarg(0); - wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateLinearGradientBrush(*x1,*y1,*x2,*y2,c1,c2)); newPtr((void *) Result,3, memenv);; + wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateLinearGradientBrush(*x1,*y1,*x2,*y2,c1,c2)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsBrush"); break; } @@ -7056,7 +7056,7 @@ case wxGraphicsRenderer_CreateRadialGradientBrush: { // wxGraphicsRenderer::Crea int * cColorA = (int *) bp; bp += 4; wxColour cColor = wxColour(*cColorR,*cColorG,*cColorB,*cColorA); if(!This) throw wxe_badarg(0); - wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateRadialGradientBrush(*xo,*yo,*xc,*yc,*radius,oColor,cColor)); newPtr((void *) Result,3, memenv);; + wxGraphicsBrush * Result = new wxGraphicsBrush(This->CreateRadialGradientBrush(*xo,*yo,*xc,*yc,*radius,oColor,cColor)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsBrush"); break; } @@ -7076,7 +7076,7 @@ case wxGraphicsRenderer_CreateFont: { // wxGraphicsRenderer::CreateFont } break; }}; if(!This) throw wxe_badarg(0); - wxGraphicsFont * Result = new wxGraphicsFont(This->CreateFont(*font,col)); newPtr((void *) Result,3, memenv);; + wxGraphicsFont * Result = new wxGraphicsFont(This->CreateFont(*font,col)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsFont"); break; } @@ -7116,14 +7116,14 @@ case wxGraphicsRenderer_CreateMatrix: { // wxGraphicsRenderer::CreateMatrix } break; }}; if(!This) throw wxe_badarg(0); - wxGraphicsMatrix * Result = new wxGraphicsMatrix(This->CreateMatrix(a,b,c,d,tx,ty)); newPtr((void *) Result,3, memenv);; + wxGraphicsMatrix * Result = new wxGraphicsMatrix(This->CreateMatrix(a,b,c,d,tx,ty)); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsMatrix"); break; } case wxGraphicsRenderer_CreatePath: { // wxGraphicsRenderer::CreatePath wxGraphicsRenderer *This = (wxGraphicsRenderer *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); - wxGraphicsPath * Result = new wxGraphicsPath(This->CreatePath()); newPtr((void *) Result,3, memenv);; + wxGraphicsPath * Result = new wxGraphicsPath(This->CreatePath()); newPtr((void *) Result,4, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxGraphicsPath"); break; } @@ -32071,7 +32071,20 @@ case wxDCOverlay_Clear: { // wxDCOverlay::Clear bool WxeApp::delete_object(void *ptr, wxeRefData *refd) { + if(wxe_debug) { + wxString msg; + const wxChar *class_info = wxT("unknown"); + if(refd->type < 10) { + wxClassInfo *cinfo = ((wxObject *)ptr)->GetClassInfo(); + class_info = cinfo->GetClassName(); + } + msg.Printf(wxT("Deleting {wx_ref, %d, %s} at %p "), refd->ref, class_info, ptr); + send_msg("debug", &msg); + }; switch(refd->type) { +#if wxUSE_GRAPHICS_CONTEXT + case 4: delete (wxGraphicsObject *) ptr; break; +#endif case 24: delete (wxGridCellBoolRenderer *) ptr; break; case 25: delete (wxGridCellBoolEditor *) ptr; break; case 26: delete (wxGridCellFloatRenderer *) ptr; break; diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp index 175bcfce54..0d2da5d4a7 100644 --- a/lib/wx/c_src/wxe_impl.cpp +++ b/lib/wx/c_src/wxe_impl.cpp @@ -490,7 +490,7 @@ void WxeApp::destroyMemEnv(wxeMetaCommand& Ecmd) if(it != ptr2ref.end()) { wxeRefData *refd = it->second; if(refd->alloc_in_erl) { - if((refd->type == 4) && ((wxObject *)ptr)->IsKindOf(CLASSINFO(wxBufferedDC))) { + if((refd->type == 8) && ((wxObject *)ptr)->IsKindOf(CLASSINFO(wxBufferedDC))) { ((wxBufferedDC *)ptr)->m_dc = NULL; // Workaround } wxString msg; @@ -500,7 +500,7 @@ void WxeApp::destroyMemEnv(wxeMetaCommand& Ecmd) msg.Printf(wxT("Memory leak: {wx_ref, %d, %s}"), refd->ref, cinfo->GetClassName()); send_msg("error", &msg); - } else { + } else if(refd->type != 4) { cleanup_ref = delete_object(ptr, refd); } if(cleanup_ref) { @@ -562,7 +562,12 @@ int WxeApp::newPtr(void * ptr, int type, wxeMemEnv *memenv) { if(wxe_debug) { wxString msg; - msg.Printf(wxT("Creating {wx_ref, %d, unknown} at %p "), ref, ptr); + const wxChar *class_info = wxT("unknown"); + if(type < 10) { + wxClassInfo *cinfo = ((wxObject *)ptr)->GetClassInfo(); + class_info = cinfo->GetClassName(); + } + msg.Printf(wxT("Creating {wx_ref, %d, %s} at %p "), ref, class_info, ptr); send_msg("debug", &msg); } @@ -614,12 +619,6 @@ void WxeApp::clearPtr(void * ptr) { refd->memenv->ref2ptr[ref] = NULL; free.Append(ref); - if(wxe_debug) { - wxString msg; - msg.Printf(wxT("Deleting {wx_ref, %d, unknown} at %p "), ref, ptr); - send_msg("debug", &msg); - } - if(((int) refd->pid) != -1) { // Send terminate pid to owner wxeReturn rt = wxeReturn(WXE_DRV_PORT,refd->pid, false); diff --git a/lib/wx/c_src/wxe_memory.h b/lib/wx/c_src/wxe_memory.h index 455e9696d3..66c83e40c3 100644 --- a/lib/wx/c_src/wxe_memory.h +++ b/lib/wx/c_src/wxe_memory.h @@ -48,8 +48,9 @@ class wxeRefData { int type; // 0 = wxWindow subclasses, 1 = wxObject subclasses // 2 = wxDialog subclasses, 3 = allocated wxObjects but not returned from new - // 4 = wxObjects that should always be deleted directly (wxDC derivates) - // > 4 classes which lack virtual destr, or are supposed to be allocated on + // 4 = wxGraphicsObjects or it's subclasses that can no be overloaded + // 8 = wxObjects that should always be deleted directly (wxDC derivates) + // > 10 classes which lack virtual destr, or are supposed to be allocated on // the stack bool alloc_in_erl; wxeMemEnv *memenv; diff --git a/lib/wx/examples/demo/ex_graphicsContext.erl b/lib/wx/examples/demo/ex_graphicsContext.erl index d883ddfc5c..1193578037 100644 --- a/lib/wx/examples/demo/ex_graphicsContext.erl +++ b/lib/wx/examples/demo/ex_graphicsContext.erl @@ -135,6 +135,8 @@ draw(Win, Pen, Brush, Font) -> wxGraphicsContext:drawPath(Canvas, Path) end, wx:foreach(F, lists:seq(1,10)), + wxGraphicsObject:destroy(Path), + wxGraphicsObject:destroy(Canvas), ok catch _:{not_supported, _} -> Err = "wxGraphicsContext not available in this build of wxwidgets", diff --git a/lib/wx/src/gen/wxAcceleratorTable.erl b/lib/wx/src/gen/wxAcceleratorTable.erl index 5c83ffced9..4efcaaa7d0 100644 --- a/lib/wx/src/gen/wxAcceleratorTable.erl +++ b/lib/wx/src/gen/wxAcceleratorTable.erl @@ -46,7 +46,7 @@ new() -> N::integer(), Entries::[wxAcceleratorEntry:wxAcceleratorEntry()]. new(N,Entries) when is_integer(N),is_list(Entries) -> - [?CLASS(EntriesT,wxAcceleratorEntry) || #wx_ref{type=EntriesT} <- Entries], + _ = [?CLASS(EntriesT,wxAcceleratorEntry) || #wx_ref{type=EntriesT} <- Entries], wxe_util:construct(?wxAcceleratorTable_new_2, <<N:32/?UI,(length(Entries)):32/?UI, (<< <<(C#wx_ref.ref):32/?UI>> || C <- Entries>>)/binary, 0:(((0+length(Entries)) rem 2)*32)>>). |