diff options
author | Dan Gudmundsson <[email protected]> | 2011-09-28 10:26:42 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2011-09-28 10:26:42 +0200 |
commit | 4d910fc9b179cc630912165998d41a4a047148af (patch) | |
tree | 14bf4b1f2d07ec960f58d975da83f5dd2f496e2d /lib/wx | |
parent | bab81645605fef5e6c65637cbbd30f9cb30f68a4 (diff) | |
parent | 9299708cb88b5ed000cf2278df420a23e249159a (diff) | |
download | otp-4d910fc9b179cc630912165998d41a4a047148af.tar.gz otp-4d910fc9b179cc630912165998d41a4a047148af.tar.bz2 otp-4d910fc9b179cc630912165998d41a4a047148af.zip |
Merge branch 'dgud/wx/wx-bugs' into dev
* dgud/wx/wx-bugs:
[wx] Re-generate code
[wx] Remove optional shadowing clauses
[wx] Remove warning
[wx] Fix trailing whitespace
[wx] Test colors in textctrl
[wx] Fix cleanup memory references
Diffstat (limited to 'lib/wx')
-rw-r--r-- | lib/wx/api_gen/wx_gen.erl | 23 | ||||
-rw-r--r-- | lib/wx/c_src/egl_impl.cpp | 58 | ||||
-rw-r--r-- | lib/wx/c_src/wxe_impl.cpp | 188 | ||||
-rw-r--r-- | lib/wx/src/gen/wxBoxSizer.erl | 6 | ||||
-rw-r--r-- | lib/wx/src/gen/wxFlexGridSizer.erl | 6 | ||||
-rw-r--r-- | lib/wx/src/gen/wxGridBagSizer.erl | 6 | ||||
-rw-r--r-- | lib/wx/src/gen/wxGridSizer.erl | 6 | ||||
-rw-r--r-- | lib/wx/src/gen/wxSizer.erl | 26 | ||||
-rw-r--r-- | lib/wx/src/gen/wxStaticBoxSizer.erl | 6 | ||||
-rw-r--r-- | lib/wx/src/gen/wxStdDialogButtonSizer.erl | 6 | ||||
-rw-r--r-- | lib/wx/test/wx_class_SUITE.erl | 22 |
11 files changed, 180 insertions, 173 deletions
diff --git a/lib/wx/api_gen/wx_gen.erl b/lib/wx/api_gen/wx_gen.erl index b36653c570..209de48496 100644 --- a/lib/wx/api_gen/wx_gen.erl +++ b/lib/wx/api_gen/wx_gen.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -30,6 +30,12 @@ -compile(export_all). +-define(DBGCF(Class, Func, Format, Args), + case {get(current_class), get(current_func)} of + {Class, Func} -> io:format("~p:~p: " ++ Format, [?MODULE,?LINE] ++ Args); + _ -> ok + end). + code() -> safe(fun gen_code/0,true). xml() -> safe(fun gen_xml/0,true). @@ -957,17 +963,17 @@ erl_skip_opt(All=[Ms=[{_,{Len,_,_},_}|_]|R],Acc1=[{_,{N,_,_},_}|_], Acc2) -> end; erl_skip_opt([],Acc1,Acc2) -> [strip_ti(Acc1)|Acc2]. -erl_skip_opt2([F={_,{N,In,_},M=#method{where=Where}}|Ms],Acc1,Acc2,Check) -> +erl_skip_opt2([F={_,{N,In,_},M=#method{where=Where}}|Ms],Acc1,Acc2,Check) -> case N > 0 andalso lists:last(In) =:= opt_list of - true when Where =/= merged_c, Where =/= taylormade -> - case Check of - [] -> + true when Where =/= merged_c, Where =/= taylormade -> + case Check of + [] -> erl_skip_opt2(Ms,[F|Acc1],[M#method{where=erl_no_opt}|Acc2],[]); - _ -> + _ -> Skipped = reverse(tl(reverse(In))), T = fun({_,{_,Args,_},_}) -> true =:= types_differ(Skipped,Args) end, case lists:all(T, Check) of - true -> + true -> erl_skip_opt2(Ms,[F|Acc1], [M#method{where=erl_no_opt}|Acc2], Check); @@ -976,7 +982,7 @@ erl_skip_opt2([F={_,{N,In,_},M=#method{where=Where}}|Ms],Acc1,Acc2,Check) -> end end; _ -> - erl_skip_opt2(Ms,[F|Acc1],Acc2,[]) + erl_skip_opt2(Ms,[F|Acc1],Acc2,Check) end; erl_skip_opt2([],Acc1,Acc2,_) -> {Acc1,Acc2}. @@ -1025,7 +1031,6 @@ types_differ([{class,C1}|R1], [{class,C2}|R2]) -> true -> true; false -> -%% _ -> {class,C1,C2}; {class,C1,C2} -> {class,C1,C2}; diff --git a/lib/wx/c_src/egl_impl.cpp b/lib/wx/c_src/egl_impl.cpp index e2dbbb73c4..6d873abc44 100644 --- a/lib/wx/c_src/egl_impl.cpp +++ b/lib/wx/c_src/egl_impl.cpp @@ -1,20 +1,20 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2010. All Rights Reserved. - * + * + * Copyright Ericsson AB 2011. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * - * %CopyrightEnd% + * + * %CopyrightEnd% */ #include <stdio.h> @@ -35,8 +35,8 @@ void init_tess(); void exit_tess(); int load_gl_functions(); -/* **************************************************************************** - * OPENGL INITIALIZATION +/* **************************************************************************** + * OPENGL INITIALIZATION *****************************************************************************/ int egl_initiated = 0; @@ -51,7 +51,7 @@ void * dlsym(HMODULE Lib, const char *func) { void * funcp; if((funcp = (void *) GetProcAddress(Lib, func))) return funcp; - else + else return (void *) wglGetProcAddress(func); } @@ -73,14 +73,14 @@ typedef char DL_CHAR; # define OPENGL_LIB "libGL.so" # define OPENGLU_LIB "libGLU.so" # endif -#endif +#endif extern "C" { -DRIVER_INIT(EGL_DRIVER) { +DRIVER_INIT(EGL_DRIVER) { return NULL; } } -int egl_init_opengl(void *erlCallbacks) +int egl_init_opengl(void *erlCallbacks) { #ifdef _WIN32 driver_init((TWinDynDriverCallbacks *) erlCallbacks); @@ -95,7 +95,7 @@ int egl_init_opengl(void *erlCallbacks) } int load_gl_functions() { - DL_CHAR * DLName = OPENGL_LIB; + DL_CHAR * DLName = (DL_CHAR *) OPENGL_LIB; DL_LIB_P LIBhandle = dlopen(DLName, RTLD_LAZY); //fprintf(stderr, "Loading GL: %s\r\n", (const char*)DLName); void * func = NULL; @@ -127,13 +127,13 @@ int load_gl_functions() { fprintf(stderr, "Could NOT load OpenGL library: %s\r\n", DLName); }; - DLName = OPENGLU_LIB; + DLName = (DL_CHAR *) OPENGLU_LIB; LIBhandle = dlopen(DLName, RTLD_LAZY); // fprintf(stderr, "Loading GLU: %s\r\n", (const char*)DLName); func = NULL; if(LIBhandle) { - for(i=0; glu_fns[i].name != NULL; i++) { + for(i=0; glu_fns[i].name != NULL; i++) { if((func = dlsym(LIBhandle, glu_fns[i].name))) { * (void **) (glu_fns[i].func) = func; } else { @@ -201,7 +201,7 @@ egl_ogla_error(GLenum errorCode) void CALLBACK egl_ogla_combine(GLdouble coords[3], void* vertex_data[4], - GLfloat w[4], + GLfloat w[4], void **dataOut) { GLdouble* vertex = tess_alloc_vertex; @@ -226,7 +226,7 @@ egl_ogla_combine(GLdouble coords[3], *dataOut = vertex; } -void init_tess() +void init_tess() { tess = gluNewTess(); @@ -237,7 +237,7 @@ void init_tess() } -void exit_tess() +void exit_tess() { gluDeleteTess(tess); } @@ -251,22 +251,22 @@ int erl_tess_impl(char* buff, ErlDrvPort port, ErlDrvTermData caller) int num_vertices; GLdouble *n; int n_pos, AP, res; - + num_vertices = * (int *) buff; buff += 8; /* Align */ n = (double *) buff; buff += 8*3; - bin = driver_alloc_binary(num_vertices*6*sizeof(GLdouble)); + bin = driver_alloc_binary(num_vertices*6*sizeof(GLdouble)); new_vertices = tess_coords = (double *) bin->orig_bytes; memcpy(tess_coords,buff,num_vertices*3*sizeof(GLdouble)); tess_alloc_vertex = tess_coords + num_vertices*3; #if 0 fprintf(stderr, "n=%d\r\n", num_vertices); -#endif +#endif vertices = (int *) driver_alloc(sizeof(int) * 16*num_vertices); - + tess_vertices = vertices; - + gluTessNormal(tess, n[0], n[1], n[2]); gluTessBeginPolygon(tess, 0); gluTessBeginContour(tess); @@ -275,9 +275,9 @@ int erl_tess_impl(char* buff, ErlDrvPort port, ErlDrvTermData caller) } gluTessEndContour(tess); gluTessEndPolygon(tess); - - n_pos = (tess_vertices - vertices); - + + n_pos = (tess_vertices - vertices); + AP = 0; ErlDrvTermData *rt; rt = (ErlDrvTermData *) driver_alloc(sizeof(ErlDrvTermData) * (13+n_pos*2)); rt[AP++]=ERL_DRV_ATOM; rt[AP++]=driver_mk_atom((char *) "_egl_result_"); @@ -287,12 +287,12 @@ int erl_tess_impl(char* buff, ErlDrvPort port, ErlDrvTermData caller) }; rt[AP++] = ERL_DRV_NIL; rt[AP++] = ERL_DRV_LIST; rt[AP++] = n_pos+1; - rt[AP++] = ERL_DRV_BINARY; rt[AP++] = (ErlDrvTermData) bin; + rt[AP++] = ERL_DRV_BINARY; rt[AP++] = (ErlDrvTermData) bin; rt[AP++] = (tess_alloc_vertex-new_vertices)*sizeof(GLdouble); rt[AP++] = 0; - + rt[AP++] = ERL_DRV_TUPLE; rt[AP++] = 2; // Return tuple {list, Bin} rt[AP++] = ERL_DRV_TUPLE; rt[AP++] = 2; // Result tuple - + res = driver_send_term(port,caller,rt,AP); /* fprintf(stderr, "List %d: %d %d %d \r\n", */ /* res, */ diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp index 95755978f1..e430fbc7a2 100644 --- a/lib/wx/c_src/wxe_impl.cpp +++ b/lib/wx/c_src/wxe_impl.cpp @@ -14,7 +14,7 @@ * the License for the specific language governing rights and limitations * under the License. * - * %CopyrightEnd% + * %CopyrightEnd% */ #include <stdio.h> @@ -49,7 +49,7 @@ DEFINE_EVENT_TYPE(wxeEVT_META_COMMAND) #define WXE_NORMAL 0 #define WXE_CALLBACK 1 -#define WXE_STORED 2 +#define WXE_STORED 2 ErlDrvTid wxe_thread; @@ -67,7 +67,7 @@ wxList * wxe_batch_cb_saved = NULL; ErlDrvTermData wxe_batch_caller = 0; ErlDrvTermData init_caller = 0; -// extern opengl +// extern opengl void gl_dispatch(int op, char *bp, ErlDrvTermData caller, WXEBinRef *bins[]); @@ -99,7 +99,7 @@ void *wxe_main_loop(void * ); * START AND STOP of driver thread * ************************************************************/ -int load_native_gui() +int load_native_gui() { return 1; } @@ -112,7 +112,7 @@ int start_native_gui(wxe_data *sd) wxe_batch_locker_m = erl_drv_mutex_create((char *)"wxe_batch_locker_m"); wxe_batch_locker_c = erl_drv_cond_create((char *)"wxe_batch_locker_c"); - init_caller = driver_connected(sd->port); + init_caller = driver_connected(sd->port); #ifdef __DARWIN__ res = erl_drv_steal_main_thread((char *)"wxwidgets", @@ -152,9 +152,9 @@ void stop_native_gui(wxe_data *sd) erl_drv_cond_destroy(wxe_batch_locker_c); } -void unload_native_gui() +void unload_native_gui() { - + } /* ************************************************************ @@ -162,13 +162,13 @@ void unload_native_gui() * Called by emulator thread * ************************************************************/ -void push_command(int op,char * buf,int len, wxe_data *sd) -{ +void push_command(int op,char * buf,int len, wxe_data *sd) +{ // fprintf(stderr, "Op %d %d\r\n", op, (int) driver_caller(sd->port)),fflush(stderr); wxeCommand *Cmd = new wxeCommand(op, buf, len, sd); erl_drv_mutex_lock(wxe_batch_locker_m); wxe_batch->Append(Cmd); - + if(wxe_batch_caller > 0) { // wx-thread is waiting on batch end in cond_wait erl_drv_cond_signal(wxe_batch_locker_c); @@ -179,11 +179,11 @@ void push_command(int op,char * buf,int len, wxe_data *sd) } erl_drv_cond_signal(wxe_batch_locker_c); wxWakeUpIdle(); - } + } erl_drv_mutex_unlock(wxe_batch_locker_m); } -void meta_command(int what, wxe_data *sd) { +void meta_command(int what, wxe_data *sd) { if(what == PING_PORT) { erl_drv_mutex_lock(wxe_batch_locker_m); if(wxe_batch_caller > 0) { @@ -203,17 +203,17 @@ void meta_command(int what, wxe_data *sd) { } /* ************************************************************ - * wxWidgets Thread + * wxWidgets Thread * ************************************************************/ void *wxe_main_loop(void *vpdl) { - int result; + int result; int argc = 1; char * temp = (char *) "Erlang"; char * argv[] = {temp,NULL}; ErlDrvPDL pdl = (ErlDrvPDL) vpdl; - + driver_pdl_inc_refc(pdl); // ErlDrvSysInfo einfo; @@ -223,7 +223,7 @@ void *wxe_main_loop(void *vpdl) #ifndef _WIN32 erts_thread_disable_fpe(); #endif - + result = wxEntry(argc, argv); // fprintf(stderr, "WXWidgets quits main loop %d \r\n", result); if(result >= 0 && wxe_status == WXE_INITIATED) { @@ -240,17 +240,17 @@ void *wxe_main_loop(void *vpdl) erl_drv_cond_signal(wxe_status_c); erl_drv_mutex_unlock(wxe_status_m); driver_pdl_dec_refc(pdl); - return NULL; + return NULL; } } wxFrame * dummy_window; void create_dummy_window() { - dummy_window = new wxFrame(NULL,-1, wxT("wx driver"), - wxDefaultPosition, wxSize(5,5), + dummy_window = new wxFrame(NULL,-1, wxT("wx driver"), + wxDefaultPosition, wxSize(5,5), wxFRAME_NO_TASKBAR); - dummy_window->Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, + dummy_window->Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, (wxObjectEventFunction) (wxEventFunction) &WxeApp::dummy_close); } @@ -262,7 +262,7 @@ void WxeApp::dummy_close(wxEvent& Ev) { create_dummy_window(); } -// Init wx-widgets thread +// Init wx-widgets thread bool WxeApp::OnInit() { wxe_ps_init(); @@ -274,13 +274,13 @@ bool WxeApp::OnInit() wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED); - this->Connect(wxID_ANY, wxEVT_IDLE, + this->Connect(wxID_ANY, wxEVT_IDLE, (wxObjectEventFunction) (wxEventFunction) &WxeApp::idle); - this->Connect(CREATE_PORT, wxeEVT_META_COMMAND, + this->Connect(CREATE_PORT, wxeEVT_META_COMMAND, (wxObjectEventFunction) (wxEventFunction) &WxeApp::newMemEnv); - this->Connect(DELETE_PORT, wxeEVT_META_COMMAND, + this->Connect(DELETE_PORT, wxeEVT_META_COMMAND, (wxObjectEventFunction) (wxEventFunction) &WxeApp::destroyMemEnv); - this->Connect(WXE_SHUTDOWN, wxeEVT_META_COMMAND, + this->Connect(WXE_SHUTDOWN, wxeEVT_META_COMMAND, (wxObjectEventFunction) (wxEventFunction) &WxeApp::shutdown); // fprintf(stderr, "Size void* %d: long %d long long %d int64 %d \r\n", @@ -288,9 +288,9 @@ bool WxeApp::OnInit() initEventTable(); wxInitAllImageHandlers(); - /* Create a dummy window so wxWidgets don't automagicly quits the main loop + /* Create a dummy window so wxWidgets don't automagicly quits the main loop after the last window */ - create_dummy_window(); + create_dummy_window(); init_nonconsts(global_me, init_caller); erl_drv_mutex_lock(wxe_status_m); @@ -309,19 +309,19 @@ void send_msg(const char * type, wxString * msg) { wxeReturn rt = wxeReturn(WXE_DRV_PORT, init_caller); rt.addAtom((char *) "wxe_driver"); rt.addAtom((char *) type); - rt.add(msg); + rt.add(msg); rt.addTupleCount(3); rt.send(); } /* ************************************************************ - * Erlang Command execution * + * Erlang Command execution * * ************************************************************/ -/* Callback from printer and event callbacks */ +/* Callback from printer and event callbacks */ void pre_callback() { - // no-op + // no-op } void handle_event_callback(ErlDrvPort port, ErlDrvTermData process) @@ -343,7 +343,7 @@ void handle_event_callback(ErlDrvPort port, ErlDrvTermData process) void WxeApp::idle(wxIdleEvent& event) { dispatch_cmds(); } - + void WxeApp::dispatch_cmds() { erl_drv_mutex_lock(wxe_batch_locker_m); int level = dispatch(wxe_batch_cb_saved, 0, WXE_STORED); @@ -352,14 +352,14 @@ void WxeApp::dispatch_cmds() { erl_drv_mutex_unlock(wxe_batch_locker_m); } -// Should have erl_drv_mutex_lock(wxe_batch_locker_m); -// when entering this function and it should be released +// Should have erl_drv_mutex_lock(wxe_batch_locker_m); +// when entering this function and it should be released // afterwards -int WxeApp::dispatch(wxList * batch, int blevel, int list_type) +int WxeApp::dispatch(wxList * batch, int blevel, int list_type) { int ping = 0; // erl_drv_mutex_lock(wxe_batch_locker_m); must be locked already - while(true) + while(true) { if (batch->size() > 0) { for( wxList::compatibility_iterator node = batch->GetFirst(); @@ -376,10 +376,10 @@ int WxeApp::dispatch(wxList * batch, int blevel, int list_type) {blevel++; } break; case WXE_DEBUG_PING: - // When in debugger we don't want to hang waiting for a BATCH_END + // When in debugger we don't want to hang waiting for a BATCH_END // that never comes, because a breakpoint have hit. ping++; - if(ping > 2) + if(ping > 2) blevel = 0; break; case WXE_CB_RETURN: @@ -391,7 +391,7 @@ int WxeApp::dispatch(wxList * batch, int blevel, int list_type) } return blevel; default: - erl_drv_mutex_unlock(wxe_batch_locker_m); + erl_drv_mutex_unlock(wxe_batch_locker_m); if(event->op < OPENGL_START) { // fprintf(stderr, " c %d (%d) \r\n", event->op, blevel); wxe_dispatch(*event); @@ -430,10 +430,10 @@ void WxeApp::dispatch_cb(wxList * batch, wxList * temp, ErlDrvTermData process) wxeCommand *event = (wxeCommand *)node->GetData(); wxeMemEnv *memenv = getMemEnv(event->port); batch->Erase(node); - if(event->caller == process || // Callbacks from CB process only + if(event->caller == process || // Callbacks from CB process only event->op == WXE_CB_START || // Recursive event callback allow // Allow connect_cb during CB i.e. msg from wxe_server. - (memenv && event->caller == memenv->owner)) + (memenv && event->caller == memenv->owner)) { switch(event->op) { case WXE_BATCH_END: @@ -461,7 +461,7 @@ void WxeApp::dispatch_cb(wxList * batch, wxList * temp, ErlDrvTermData process) } erl_drv_mutex_lock(wxe_batch_locker_m); break; - if(callback_returned) + if(callback_returned) return; } delete event; @@ -491,13 +491,13 @@ void WxeApp::newMemEnv(wxeMetaCommand& Ecmd) { driver_pdl_inc_refc(Ecmd.pdl); for(int i = 0; i < global_me->next; i++) { - memenv->ref2ptr[i] = global_me->ref2ptr[i]; + memenv->ref2ptr[i] = global_me->ref2ptr[i]; } memenv->next = global_me->next; refmap[(ErlDrvTermData) Ecmd.port] = memenv; memenv->owner = Ecmd.caller; - ErlDrvTermData rt[] = {ERL_DRV_ATOM, driver_mk_atom((char *)"wx_port_initiated")}; + ErlDrvTermData rt[] = {ERL_DRV_ATOM, driver_mk_atom((char *)"wx_port_initiated")}; driver_send_term(WXE_DRV_PORT,Ecmd.caller,rt,2); } @@ -516,13 +516,13 @@ void WxeApp::destroyMemEnv(wxeMetaCommand& Ecmd) { // pre-pass delete all dialogs first since they might crash erlang otherwise for(int i=1; i < memenv->next; i++) { wxObject * ptr = (wxObject *) memenv->ref2ptr[i]; - if(ptr) { + if(ptr) { ptrMap::iterator it = ptr2ref.find(ptr); if(it != ptr2ref.end()) { wxeRefData *refd = it->second; if(refd->alloc_in_erl) { if(refd->type == 2) { - wxDialog *win = (wxDialog *) ptr; + wxDialog *win = (wxDialog *) ptr; if(win->IsModal()) { win->EndModal(-1); } @@ -532,25 +532,25 @@ void WxeApp::destroyMemEnv(wxeMetaCommand& Ecmd) { if(parentRef == ptr2ref.end()) { // The parent is already dead delete the parent ref win->SetParent(NULL); - } + } } delete win; - } + } } } } } - // First pass, delete all top parents/windows of all linked objects + // First pass, delete all top parents/windows of all linked objects // fprintf(stderr, "close port %x\r\n", Ecmd.port);fflush(stderr); for(int i=1; i < memenv->next; i++) { void * ptr = memenv->ref2ptr[i]; - if(ptr) { + if(ptr) { ptrMap::iterator it = ptr2ref.find(ptr); if(it != ptr2ref.end()) { wxeRefData *refd = it->second; if(refd->alloc_in_erl && refd->type == 0) { - parent = (wxWindow *) ptr; + parent = (wxWindow *) ptr; // fprintf(stderr, "window %x %d\r\n", (int) parent, refd->ref); while(parent->GetParent()) { parent = parent->GetParent(); @@ -570,7 +570,7 @@ void WxeApp::destroyMemEnv(wxeMetaCommand& Ecmd) { // everything linked from windows should now be deleted for(int i=1; i < memenv->next; i++) { void * ptr = memenv->ref2ptr[i]; - if(ptr) { + if(ptr) { ptrMap::iterator it = ptr2ref.find(ptr); if(it != ptr2ref.end()) { wxeRefData *refd = it->second; @@ -582,33 +582,33 @@ void WxeApp::destroyMemEnv(wxeMetaCommand& Ecmd) { wxString msg; if((refd->type == 0)) { // Maybe also class 1 wxClassInfo *cinfo = ((wxObject *)ptr)->GetClassInfo(); - msg.Printf(wxT("Memory leak: {wx_ref, %d, %s}"), + msg.Printf(wxT("Memory leak: {wx_ref, %d, %s}"), refd->ref, cinfo->GetClassName()); send_msg("error", &msg); } else { delete_object(ptr, refd); } - if(type == 0 || type > 3) { - // Delete refs for leaks and non overridden allocs + if(type == 0 || type > 2) { + // Delete refs for leaks and non overridden allocs delete refd; ptr2ref.erase(it); } // overridden allocs deletes meta-data in clearPtr } else { // Not alloced in erl just delete references if(refd->ref >= global_me->next) { // if it is not part of global ptrs - delete refd; + delete refd; ptr2ref.erase(it); } } } } - } - // Assert ? -// for(ptrMap::iterator it = ptr2ref.begin(); it != ptr2ref.end(); it++) { -// wxeRefData *refd = it->second; -// if(refd->ref >= global_me->next) -// fprintf(stderr, "L %d %d\r\n", refd->ref, refd->alloc_in_erl); -// } -// fflush(stderr); + } +// // Assert ? +// for(ptrMap::iterator it = ptr2ref.begin(); it != ptr2ref.end(); it++) { +// wxeRefData *refd = it->second; +// if(refd->ref >= global_me->next) +// fprintf(stderr, "L %d %d %d\r\n", refd->ref, refd->type, refd->alloc_in_erl); +// } +// fflush(stderr); delete memenv; driver_pdl_dec_refc(Ecmd.pdl); refmap.erase((ErlDrvTermData) Ecmd.port); @@ -621,7 +621,7 @@ wxeMemEnv * WxeApp::getMemEnv(ErlDrvPort port) { int WxeApp::newPtr(void * ptr, int type, wxeMemEnv *memenv) { int ref; intList free = memenv->free; - + if(free.IsEmpty()) { ref = memenv->next++; } else { @@ -629,8 +629,8 @@ int WxeApp::newPtr(void * ptr, int type, wxeMemEnv *memenv) { }; if(ref >= memenv->max) { memenv->max *= 2; - memenv->ref2ptr = - (void **) driver_realloc(memenv->ref2ptr,memenv->max * sizeof(void*)); + memenv->ref2ptr = + (void **) driver_realloc(memenv->ref2ptr,memenv->max * sizeof(void*)); } memenv->ref2ptr[ref] = ptr; @@ -650,12 +650,12 @@ int WxeApp::getRef(void * ptr, wxeMemEnv *memenv) { ptrMap::iterator it = ptr2ref.find(ptr); if(it != ptr2ref.end()) { wxeRefData *refd = it->second; - if(refd->memenv == memenv) { + if(refd->memenv == memenv || refd->memenv == global_me) { // Found it return return refd->ref; } // else // Old reference to deleted object, release old and recreate in current memenv. - clearPtr(ptr); + ptr2ref.erase(it); } int ref; intList free = memenv->free; @@ -684,7 +684,7 @@ void WxeApp::clearPtr(void * ptr) { if(it != ptr2ref.end()) { wxeRefData *refd = it->second; intList free = refd->memenv->free; - int ref = refd->ref; + int ref = refd->ref; refd->memenv->ref2ptr[ref] = NULL; free.Append(ref); @@ -693,7 +693,7 @@ void WxeApp::clearPtr(void * ptr) { 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->memenv->owner, false); @@ -706,30 +706,30 @@ void WxeApp::clearPtr(void * ptr) { if(refd->type == 1 && ((wxObject*)ptr)->IsKindOf(CLASSINFO(wxSizer))) { wxSizerItemList list = ((wxSizer*)ptr)->GetChildren(); for(wxSizerItemList::compatibility_iterator node = list.GetFirst(); - node; node = node->GetNext()) { + node; node = node->GetNext()) { wxSizerItem *item = node->GetData(); wxObject *content=NULL; - if((content = item->GetWindow())) + if((content = item->GetWindow())) if(ptr2ref.end() == ptr2ref.find(content)) { wxString msg; wxClassInfo *cinfo = ((wxObject *)ptr)->GetClassInfo(); msg.Printf(wxT("Double usage detected of window at %p in sizer {wx_ref, %d, %s}"), content, ref, cinfo->GetClassName()); send_msg("error", &msg); - ((wxSizer*)ptr)->Detach((wxWindow*)content); + ((wxSizer*)ptr)->Detach((wxWindow*)content); } - if((content = item->GetSizer())) + if((content = item->GetSizer())) if(ptr2ref.end() == ptr2ref.find(content)) { wxString msg; wxClassInfo *cinfo = ((wxObject *)ptr)->GetClassInfo(); msg.Printf(wxT("Double usage detected of sizer at %p in sizer {wx_ref, %d, %s}"), content, ref, cinfo->GetClassName()); send_msg("error", &msg); - ((wxSizer*)ptr)->Detach((wxSizer*)content); + ((wxSizer*)ptr)->Detach((wxSizer*)content); } } } - + delete refd; ptr2ref.erase(it); } @@ -750,7 +750,7 @@ void * WxeApp::getPtr(char * bp, wxeMemEnv *memenv) { void WxeApp::registerPid(char * bp, ErlDrvTermData pid, wxeMemEnv * memenv) { int index = *(int *) bp; - if(!memenv) + if(!memenv) throw wxe_badarg(index); void * temp = memenv->ref2ptr[index]; if((index < memenv->next) && ((index == 0) || (temp > NULL))) { @@ -770,14 +770,14 @@ void WxeApp::registerPid(char * bp, ErlDrvTermData pid, wxeMemEnv * memenv) { * Misc utility classes * ************************************************************/ -/* **************************************************************************** - * Memory handling +/* **************************************************************************** + * Memory handling * ****************************************************************************/ wxeMemEnv::wxeMemEnv() { - ref2ptr = (void **) driver_alloc(128*sizeof(void *)); + ref2ptr = (void **) driver_alloc(128*sizeof(void *)); ref2ptr[0] = NULL; - next = 1; + next = 1; max = 128; } @@ -785,12 +785,12 @@ wxeMemEnv::~wxeMemEnv() { driver_free(ref2ptr); } -/* **************************************************************************** +/* **************************************************************************** * Erlang Commands (don't need to be derived of wxEvent anymore should * be re-written to own class struct) * ****************************************************************************/ -wxeCommand::wxeCommand(int fc,char * cbuf,int buflen, wxe_data *sd) +wxeCommand::wxeCommand(int fc,char * cbuf,int buflen, wxe_data *sd) : wxObject() { WXEBinRef *temp, *start, *prev; @@ -806,12 +806,12 @@ wxeCommand::wxeCommand(int fc,char * cbuf,int buflen, wxe_data *sd) if(cbuf) { buffer = (char *) driver_alloc(len); memcpy((void *) buffer, (void *) cbuf, len);; - + temp = sd->bin; - + prev = NULL; start = temp; - + while(temp) { if(caller == temp->from) { bin[n++] = temp; @@ -836,7 +836,7 @@ wxeCommand::~wxeCommand() { int n = 0; if(buffer) { while(bin[n]) { - if(bin[n]->bin) + if(bin[n]->bin) driver_free_binary(bin[n]->bin); driver_free(bin[n++]); } @@ -844,26 +844,26 @@ wxeCommand::~wxeCommand() { } } -/* **************************************************************************** - * TreeItemData +/* **************************************************************************** + * TreeItemData * ****************************************************************************/ -wxETreeItemData::wxETreeItemData(int sz, char * data) { +wxETreeItemData::wxETreeItemData(int sz, char * data) { size = sz; bin = (char *) driver_alloc(sz); memcpy(bin, data, sz); } -wxETreeItemData::~wxETreeItemData() +wxETreeItemData::~wxETreeItemData() { driver_free(bin); } -/* **************************************************************************** +/* **************************************************************************** * CallbackData * * ****************************************************************************/ -wxeCallbackData::wxeCallbackData(ErlDrvTermData caller,void * req, char *req_type, +wxeCallbackData::wxeCallbackData(ErlDrvTermData caller,void * req, char *req_type, int funcb, int skip_ev, wxeErlTerm * userData) : wxObject() { diff --git a/lib/wx/src/gen/wxBoxSizer.erl b/lib/wx/src/gen/wxBoxSizer.erl index 1d5b1cf2fa..e6287945a9 100644 --- a/lib/wx/src/gen/wxBoxSizer.erl +++ b/lib/wx/src/gen/wxBoxSizer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -102,7 +102,7 @@ prepend(This,Width,Height, Options) -> wxSizer:prepend(This,Width,Height, Option %% @hidden prepend(This,Width,Height) -> wxSizer:prepend(This,Width,Height). %% @hidden -prepend(This,Window) -> wxSizer:prepend(This,Window). +prepend(This,Item) -> wxSizer:prepend(This,Item). %% @hidden layout(This) -> wxSizer:layout(This). %% @hidden @@ -118,7 +118,7 @@ insert(This,Index,Width,Height, Options) -> wxSizer:insert(This,Index,Width,Heig %% @hidden insert(This,Index,Width,Height) -> wxSizer:insert(This,Index,Width,Height). %% @hidden -insert(This,Index,Window) -> wxSizer:insert(This,Index,Window). +insert(This,Index,Item) -> wxSizer:insert(This,Index,Item). %% @hidden hide(This,Window, Options) -> wxSizer:hide(This,Window, Options). %% @hidden diff --git a/lib/wx/src/gen/wxFlexGridSizer.erl b/lib/wx/src/gen/wxFlexGridSizer.erl index 9471cc8a01..910cc78894 100644 --- a/lib/wx/src/gen/wxFlexGridSizer.erl +++ b/lib/wx/src/gen/wxFlexGridSizer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -222,7 +222,7 @@ prepend(This,Width,Height, Options) -> wxSizer:prepend(This,Width,Height, Option %% @hidden prepend(This,Width,Height) -> wxSizer:prepend(This,Width,Height). %% @hidden -prepend(This,Window) -> wxSizer:prepend(This,Window). +prepend(This,Item) -> wxSizer:prepend(This,Item). %% @hidden layout(This) -> wxSizer:layout(This). %% @hidden @@ -238,7 +238,7 @@ insert(This,Index,Width,Height, Options) -> wxSizer:insert(This,Index,Width,Heig %% @hidden insert(This,Index,Width,Height) -> wxSizer:insert(This,Index,Width,Height). %% @hidden -insert(This,Index,Window) -> wxSizer:insert(This,Index,Window). +insert(This,Index,Item) -> wxSizer:insert(This,Index,Item). %% @hidden hide(This,Window, Options) -> wxSizer:hide(This,Window, Options). %% @hidden diff --git a/lib/wx/src/gen/wxGridBagSizer.erl b/lib/wx/src/gen/wxGridBagSizer.erl index d8cc210d3b..cfc182cf89 100644 --- a/lib/wx/src/gen/wxGridBagSizer.erl +++ b/lib/wx/src/gen/wxGridBagSizer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -474,7 +474,7 @@ prepend(This,Width,Height, Options) -> wxSizer:prepend(This,Width,Height, Option %% @hidden prepend(This,Width,Height) -> wxSizer:prepend(This,Width,Height). %% @hidden -prepend(This,Window) -> wxSizer:prepend(This,Window). +prepend(This,Item) -> wxSizer:prepend(This,Item). %% @hidden layout(This) -> wxSizer:layout(This). %% @hidden @@ -490,7 +490,7 @@ insert(This,Index,Width,Height, Options) -> wxSizer:insert(This,Index,Width,Heig %% @hidden insert(This,Index,Width,Height) -> wxSizer:insert(This,Index,Width,Height). %% @hidden -insert(This,Index,Window) -> wxSizer:insert(This,Index,Window). +insert(This,Index,Item) -> wxSizer:insert(This,Index,Item). %% @hidden hide(This,Window, Options) -> wxSizer:hide(This,Window, Options). %% @hidden diff --git a/lib/wx/src/gen/wxGridSizer.erl b/lib/wx/src/gen/wxGridSizer.erl index 7b62774347..fd8580c70d 100644 --- a/lib/wx/src/gen/wxGridSizer.erl +++ b/lib/wx/src/gen/wxGridSizer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -174,7 +174,7 @@ prepend(This,Width,Height, Options) -> wxSizer:prepend(This,Width,Height, Option %% @hidden prepend(This,Width,Height) -> wxSizer:prepend(This,Width,Height). %% @hidden -prepend(This,Window) -> wxSizer:prepend(This,Window). +prepend(This,Item) -> wxSizer:prepend(This,Item). %% @hidden layout(This) -> wxSizer:layout(This). %% @hidden @@ -190,7 +190,7 @@ insert(This,Index,Width,Height, Options) -> wxSizer:insert(This,Index,Width,Heig %% @hidden insert(This,Index,Width,Height) -> wxSizer:insert(This,Index,Width,Height). %% @hidden -insert(This,Index,Window) -> wxSizer:insert(This,Index,Window). +insert(This,Index,Item) -> wxSizer:insert(This,Index,Item). %% @hidden hide(This,Window, Options) -> wxSizer:hide(This,Window, Options). %% @hidden diff --git a/lib/wx/src/gen/wxSizer.erl b/lib/wx/src/gen/wxSizer.erl index 716b2224b5..e9b83a7333 100644 --- a/lib/wx/src/gen/wxSizer.erl +++ b/lib/wx/src/gen/wxSizer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -298,18 +298,8 @@ hide(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=WindowT,ref=WindowRef}, Option wxe_util:call(WindowOP, <<ThisRef:32/?UI,WindowRef:32/?UI, BinOpt/binary>>). -%% @spec (This::wxSizer(),Index::integer(),X::term()) -> wxSizerItem:wxSizerItem() +%% @spec (This::wxSizer(), Index::integer(), Item::wxSizerItem:wxSizerItem()) -> wxSizerItem:wxSizerItem() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxsizer.html#wxsizerinsert">external documentation</a>. -%% <br /> Alternatives: -%% <p><c> -%% insert(This::wxSizer(), Index::integer(), Window::wxWindow:wxWindow() | wxSizer()) -> insert(This,Index,Window, []) </c></p> -%% <p><c> -%% insert(This::wxSizer(), Index::integer(), Item::wxSizerItem:wxSizerItem()) -> wxSizerItem:wxSizerItem() </c> -%% </p> - -insert(This,Index,Window) - when is_record(This, wx_ref),is_integer(Index),is_record(Window, wx_ref) -> - insert(This,Index,Window, []); insert(#wx_ref{type=ThisT,ref=ThisRef},Index,#wx_ref{type=ItemT,ref=ItemRef}) when is_integer(Index) -> ?CLASS(ThisT,wxSizer), @@ -437,18 +427,8 @@ layout(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:cast(?wxSizer_Layout, <<ThisRef:32/?UI>>). -%% @spec (This::wxSizer(),X::term()) -> wxSizerItem:wxSizerItem() +%% @spec (This::wxSizer(), Item::wxSizerItem:wxSizerItem()) -> wxSizerItem:wxSizerItem() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxsizer.html#wxsizerprepend">external documentation</a>. -%% <br /> Alternatives: -%% <p><c> -%% prepend(This::wxSizer(), Window::wxWindow:wxWindow() | wxSizer()) -> prepend(This,Window, []) </c></p> -%% <p><c> -%% prepend(This::wxSizer(), Item::wxSizerItem:wxSizerItem()) -> wxSizerItem:wxSizerItem() </c> -%% </p> - -prepend(This,Window) - when is_record(This, wx_ref),is_record(Window, wx_ref) -> - prepend(This,Window, []); prepend(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=ItemT,ref=ItemRef}) -> ?CLASS(ThisT,wxSizer), ?CLASS(ItemT,wxSizerItem), diff --git a/lib/wx/src/gen/wxStaticBoxSizer.erl b/lib/wx/src/gen/wxStaticBoxSizer.erl index 5f346b7a1e..2cf9f64325 100644 --- a/lib/wx/src/gen/wxStaticBoxSizer.erl +++ b/lib/wx/src/gen/wxStaticBoxSizer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -130,7 +130,7 @@ prepend(This,Width,Height, Options) -> wxSizer:prepend(This,Width,Height, Option %% @hidden prepend(This,Width,Height) -> wxSizer:prepend(This,Width,Height). %% @hidden -prepend(This,Window) -> wxSizer:prepend(This,Window). +prepend(This,Item) -> wxSizer:prepend(This,Item). %% @hidden layout(This) -> wxSizer:layout(This). %% @hidden @@ -146,7 +146,7 @@ insert(This,Index,Width,Height, Options) -> wxSizer:insert(This,Index,Width,Heig %% @hidden insert(This,Index,Width,Height) -> wxSizer:insert(This,Index,Width,Height). %% @hidden -insert(This,Index,Window) -> wxSizer:insert(This,Index,Window). +insert(This,Index,Item) -> wxSizer:insert(This,Index,Item). %% @hidden hide(This,Window, Options) -> wxSizer:hide(This,Window, Options). %% @hidden diff --git a/lib/wx/src/gen/wxStdDialogButtonSizer.erl b/lib/wx/src/gen/wxStdDialogButtonSizer.erl index b0052ca2e1..3d31907275 100644 --- a/lib/wx/src/gen/wxStdDialogButtonSizer.erl +++ b/lib/wx/src/gen/wxStdDialogButtonSizer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -139,7 +139,7 @@ prepend(This,Width,Height, Options) -> wxSizer:prepend(This,Width,Height, Option %% @hidden prepend(This,Width,Height) -> wxSizer:prepend(This,Width,Height). %% @hidden -prepend(This,Window) -> wxSizer:prepend(This,Window). +prepend(This,Item) -> wxSizer:prepend(This,Item). %% @hidden layout(This) -> wxSizer:layout(This). %% @hidden @@ -155,7 +155,7 @@ insert(This,Index,Width,Height, Options) -> wxSizer:insert(This,Index,Width,Heig %% @hidden insert(This,Index,Width,Height) -> wxSizer:insert(This,Index,Width,Height). %% @hidden -insert(This,Index,Window) -> wxSizer:insert(This,Index,Window). +insert(This,Index,Item) -> wxSizer:insert(This,Index,Item). %% @hidden hide(This,Window, Options) -> wxSizer:hide(This,Window, Options). %% @hidden diff --git a/lib/wx/test/wx_class_SUITE.erl b/lib/wx/test/wx_class_SUITE.erl index 00ef1289ab..b75b0cc74e 100644 --- a/lib/wx/test/wx_class_SUITE.erl +++ b/lib/wx/test/wx_class_SUITE.erl @@ -448,3 +448,25 @@ systemSettings(Config) -> wxWindow:show(Frame), wx_test_lib:wx_destroy(Frame,Config). + + +textCtrl(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo); +textCtrl(Config) -> + Wx = wx:new(), + Frame = wxFrame:new(Wx, ?wxID_ANY, "Frame"), + + TC = ?mt(wxTextCtrl, wxTextCtrl:new(Frame, ?wxID_ANY, [{style, ?wxTE_MULTILINE bor ?wxTE_RICH2}])), + wxTextCtrl:appendText(TC, "This line is in default color\n"), + Attr = ?mt(wxTextAttr, wxTextAttr:new(?wxRED)), + wxTextCtrl:setDefaultStyle(TC, Attr), + wxTextCtrl:appendText(TC, "This line is in ?wxRED color\n"), + wxTextAttr:setTextColour(Attr, ?wxBLACK), + wxTextCtrl:setDefaultStyle(TC, Attr), + wxTextCtrl:appendText(TC, "This line is in ?wxBLACK color\n"), + Default = wxSystemSettings:getColour(?wxSYS_COLOUR_WINDOWTEXT), + wxTextAttr:setTextColour(Attr, Default), + wxTextCtrl:setDefaultStyle(TC, Attr), + wxTextCtrl:appendText(TC, "This line is in default color\n"), + wxTextAttr:destroy(Attr), + wxWindow:show(Frame), + wx_test_lib:wx_destroy(Frame,Config). |