nobody at rubyforge.org
2007-Jun-26 18:50 UTC
[Wxruby-development] [1085] trunk/wxruby2/swig: Add checks and ruby exceptions for two common Wx::Window mistakes leading to
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:'':'';} #msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[1085] trunk/wxruby2/swig: Add checks and ruby exceptions for two common Wx::Window mistakes leading to</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1085</dd> <dt>Author</dt> <dd>brokentoy</dd> <dt>Date</dt> <dd>2007-06-26 14:50:03 -0400 (Tue, 26 Jun 2007)</dd> </dl> <h3>Log Message</h3> <pre>Add checks and ruby exceptions for two common Wx::Window mistakes leading to segfaults: instantiate outside of App.main_loop, and parent argument = nil</pre> <h3>Modified Paths</h3> <ul> <li><a href="#trunkwxruby2swigclassesBusyInfoi">trunk/wxruby2/swig/classes/BusyInfo.i</a></li> <li><a href="#trunkwxruby2swigcommoni">trunk/wxruby2/swig/common.i</a></li> <li><a href="#trunkwxruby2swigtypemapi">trunk/wxruby2/swig/typemap.i</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="trunkwxruby2swigclassesBusyInfoi"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/BusyInfo.i (1084 => 1085)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/BusyInfo.i        2007-06-26 18:41:20 UTC (rev 1084) +++ trunk/wxruby2/swig/classes/BusyInfo.i        2007-06-26 18:50:03 UTC (rev 1085) </span><span class="lines">@@ -12,6 +12,15 @@ </span><span class="cx"> </span><span class="cx"> %ignore wxBusyInfo::wxBusyInfo; </span><span class="cx"> </span><ins>+// BusyInfo is an exception to the general rule in typemap.i - it +// accepts a wxWindow* parent argument which may be null - but it does +// not inherit from TopLevelWindow - so special typemap for this class. +%typemap(check) wxWindow* parent { + if ( ! rb_const_defined(mWxruby2, rb_intern("THE_APP") ) ) +        { rb_raise(rb_eRuntimeError, +                         "Cannot create BusyInfo before App.main_loop has been called");} +} + </ins><span class="cx"> %include "include/wxBusyInfo.h" </span><span class="cx"> </span><span class="cx"> %extend wxBusyInfo { </span></span></pre></div> <a id="trunkwxruby2swigcommoni"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/common.i (1084 => 1085)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/common.i        2007-06-26 18:41:20 UTC (rev 1084) +++ trunk/wxruby2/swig/common.i        2007-06-26 18:50:03 UTC (rev 1085) </span><span class="lines">@@ -32,7 +32,9 @@ </span><span class="cx"> #error "This version of wxRuby requires WxWidgets 2.8.3 or greater" </span><span class="cx"> #endif </span><span class="cx"> </span><del>-extern VALUE mWxruby2; </del><ins>+extern VALUE mWxruby2; // The global Wxruby2 module +extern swig_class cWxTopLevelWindow; // used for wxWindow typemap in typemap.i + </ins><span class="cx"> %} </span><span class="cx"> </span><span class="cx"> %include "typedefs.i" </span></span></pre></div> <a id="trunkwxruby2swigtypemapi"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/typemap.i (1084 => 1085)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/typemap.i        2007-06-26 18:41:20 UTC (rev 1084) +++ trunk/wxruby2/swig/typemap.i        2007-06-26 18:50:03 UTC (rev 1085) </span><span class="lines">@@ -383,4 +383,19 @@ </span><span class="cx"> </span><span class="cx"> ############################################################## </span><span class="cx"> </span><ins>+// This typemap catches the first argument of all constructors and +// Create() methods for Wx::Window classes. These should not be called +// before App::main_loop is started, and, except for TopLevelWindows, +// the parent argument must not be NULL. +%typemap(check) wxWindow* parent { + if ( ! rb_const_defined(mWxruby2, rb_intern("THE_APP") ) ) +        { rb_raise(rb_eRuntimeError, +                         "Cannot create a Window before App.main_loop has been called");} + if ( ! $1 && ! rb_obj_is_kind_of(self, cWxTopLevelWindow.klass) ) +        { rb_raise(rb_eArgError, +                         "Window parent argument must not be nil"); } +} + </ins><span class="cx"> %apply int *OUTPUT { int * x , int * y , int * w, int * h }; </span><ins>+ + </ins></span></pre> </div> </div> </body> </html>
Reasonably Related Threads
- [1119] trunk/wxruby2/swig/Functions.i: Avoid erroneous ''parent must not be nil'' errors when using global
- [1099] trunk/wxruby2/swig/classes/XmlResource.i: Permit Dialogs and Frames with no parents to be created via XRC; add comments
- [1128] trunk/wxruby2/swig/common.i: Make GC_IsWindowDeleted function globally available
- [801] trunk/wxruby2/doc/textile: Explain how to use the block-style class methods in these classes
- [789] trunk/wxruby2/swig/classes/Window.i: Make GetChildren work (tho general fix for get_ruby_object still needed)