nobody at rubyforge.org
2007-May-22 08:09 UTC
[Wxruby-development] [1028] trunk/wxruby2/swig/classes/App.i: Fix some GC-mark crashes when SWIG trackings return an unexpected object
<!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>[1028] trunk/wxruby2/swig/classes/App.i: Fix some GC-mark crashes when SWIG trackings return an unexpected object</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1028</dd> <dt>Author</dt> <dd>brokentoy</dd> <dt>Date</dt> <dd>2007-05-22 04:09:51 -0400 (Tue, 22 May 2007)</dd> </dl> <h3>Log Message</h3> <pre>Fix some GC-mark crashes when SWIG trackings return an unexpected object</pre> <h3>Modified Paths</h3> <ul> <li><a href="#trunkwxruby2swigclassesAppi">trunk/wxruby2/swig/classes/App.i</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="trunkwxruby2swigclassesAppi"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/App.i (1027 => 1028)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/App.i        2007-05-21 19:06:55 UTC (rev 1027) +++ trunk/wxruby2/swig/classes/App.i        2007-05-22 08:09:51 UTC (rev 1028) </span><span class="lines">@@ -72,9 +72,12 @@ </span><span class="cx">         key = rb_ary_entry(pair, 0); </span><span class="cx">         val = rb_ary_entry(pair, 1); </span><span class="cx">         VALUE rb_obj = SWIG_RubyReferenceToObject(val); </span><del>-        // Check if it''s a descendant of Wx::Window, and if it has not yet been -        // deleted by WxWidgets. -        if ( rb_obj_is_kind_of(rb_obj, cWxWindow.klass) && </del><ins>+ +        // Check if it''s a valid object (sometimes SWIG doesn''t return what we''re +        // expecting), a descendant of Wx::Window, and if it has not yet been +        // deleted by WxWidgets; if so, mark it. +        if ( TYPE(rb_obj) == T_DATA && +                 rb_obj_is_kind_of(rb_obj, cWxWindow.klass) && </ins><span class="cx">                  rb_iv_get(rb_obj, "@__wx_destroyed__") != Qtrue ) </span><span class="cx">          { </span><span class="cx">                 rb_gc_mark(rb_obj); </span><span class="lines">@@ -82,6 +85,8 @@ </span><span class="cx">         return Qnil; </span><span class="cx"> } </span><span class="cx"> </span><ins>+ // Implements GC protection. Always called because Wx::THE_APP is a + // so always checked in GC mark phase. </ins><span class="cx"> static void mark_wxRubyApp(void *ptr) </span><span class="cx"> { </span><span class="cx"> </span><span class="lines">@@ -99,9 +104,12 @@ </span><span class="cx">                 return; </span><span class="cx">          } </span><span class="cx"> </span><ins>+        // To do the marking, iterate over SWIG''s hash list of known wrapped +        // objects (swig_ruby_trackings) and check each one. </ins><span class="cx">         rb_iterate(rb_each, swig_ruby_trackings, (VALUE(*)(...))mark_iterate, Qnil); </span><ins>+ </ins><span class="cx"> #ifdef __WXDEBUG__ </span><del>- printf("=== App GC mark phase completed\n"); </del><ins>+        printf("=== App GC mark phase completed\n"); </ins><span class="cx"> #endif </span><span class="cx"> </span><span class="cx"> } </span></span></pre> </div> </div> </body> </html>
Reasonably Related Threads
- [1136] trunk/wxruby2/swig/classes/App.i: Note when the Wx::App is exiting and avoid doing GC if in process of
- [1022] trunk/wxruby2/swig/classes/App.i: Memory mgmt: use Wx::App to mark still-alive Windows, set up Wx::THE_APP const
- [1125] trunk/wxruby2/swig/shared/control_with_items.i: Avoid MSW crashes when unexpected object is returned by SWIG tracking
- [1133] trunk/wxruby2/swig/shared/control_with_items.i: Move mark func for ControlWithItems into shared file so changes affect
- [1109] trunk/wxruby2/swig: Move marking of MenuBar from direct %markfunc to via mark_wxFrame, so