nobody at rubyforge.org
2007-Jul-18 08:40 UTC
[Wxruby-development] [1119] trunk/wxruby2/swig/Functions.i: Avoid erroneous ''parent must not be nil'' errors when using global
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.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>[1119] trunk/wxruby2/swig/Functions.i: Avoid erroneous ''parent must not be nil'' errors when using global</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1119</dd> <dt>Author</dt> <dd>brokentoy</dd> <dt>Date</dt> <dd>2007-07-18 04:40:10 -0400 (Wed, 18 Jul 2007)</dd> </dl> <h3>Log Message</h3> <pre>Avoid erroneous ''parent must not be nil'' errors when using global functions to display simple dialogs</pre> <h3>Modified Paths</h3> <ul> <li><a href="#trunkwxruby2swigFunctionsi">trunk/wxruby2/swig/Functions.i</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="trunkwxruby2swigFunctionsi"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/Functions.i (1118 => 1119)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/Functions.i        2007-07-18 08:34:46 UTC (rev 1118) +++ trunk/wxruby2/swig/Functions.i        2007-07-18 08:40:10 UTC (rev 1119) </span><span class="lines">@@ -9,8 +9,6 @@ </span><span class="cx"> // * shortcut methods for displaying simple dialogs </span><span class="cx"> // * logging functions </span><span class="cx"> // * the xrcid macro </span><del>- - </del><span class="cx"> %{ </span><span class="cx"> //NO_CLASS - This tells fixmodule not to expect a class </span><span class="cx"> </span><span class="lines">@@ -85,7 +83,7 @@ </span><span class="cx"> int ret = wxXmlResource::GetXRCID(temp); </span><span class="cx"> return INT2NUM(ret); </span><span class="cx"> } </span><del>-%} </del><ins>+%} // end of Header code </ins><span class="cx"> </span><span class="cx"> void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); </span><span class="cx"> </span><span class="lines">@@ -115,6 +113,16 @@ </span><span class="cx"> </span><span class="cx"> void wxSetWorkingDirectory(const wxString &); </span><span class="cx"> </span><ins>+// All the functions which take a parent argument in this file display +// dialogs, so the parent argument can be nil (which is not permitted in +// the normal typemap defined in typemap.i). So override the standard +// typemap and just check that the App has been started. +%typemap(check) wxWindow* parent { + if ( ! rb_const_defined(mWxruby2, rb_intern("THE_APP") ) ) +        { rb_raise(rb_eRuntimeError, +                         "Cannot display dialog before App.main_loop has been called");} +} + </ins><span class="cx"> %typemap(in,numinputs=0) wxArrayInt &selections (wxArrayInt sel) </span><span class="cx"> { </span><span class="cx">         $1 = &sel; </span></span></pre> </div> </div> </body> </html>
Apparently Analagous Threads
- [756] trunk/wxruby2/swig: Moved one-shot typemaps for ListBox.get_selections into ListBox.i
- [853] trunk/wxruby2/swig: Replace deprecated STR2CSTR with StringValuePtr
- [845] trunk/wxruby2/swig/classes: Added MultiChoiceDialog in class form
- [1118] trunk/wxruby2/swig: Move Wx::message_box function from wx.i to Functions.i, where it belongs
- [752] trunk/wxruby2: Fix for Bug #6810: ListBox#get_selections should return an array of selections