nobody at rubyforge.org
2007-May-28 19:17 UTC
[Wxruby-development] [1033] trunk/wxruby2/swig: GC fixes for nested sizers; fix crashes in html.rb demo
<!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>[1033] trunk/wxruby2/swig: GC fixes for nested sizers; fix crashes in html.rb demo</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1033</dd> <dt>Author</dt> <dd>brokentoy</dd> <dt>Date</dt> <dd>2007-05-28 15:17:14 -0400 (Mon, 28 May 2007)</dd> </dl> <h3>Log Message</h3> <pre>GC fixes for nested sizers; fix crashes in html.rb demo</pre> <h3>Modified Paths</h3> <ul> <li><a href="#trunkwxruby2swigclassesBoxSizeri">trunk/wxruby2/swig/classes/BoxSizer.i</a></li> <li><a href="#trunkwxruby2swigclassesFlexGridSizeri">trunk/wxruby2/swig/classes/FlexGridSizer.i</a></li> <li><a href="#trunkwxruby2swigclassesGridBagSizeri">trunk/wxruby2/swig/classes/GridBagSizer.i</a></li> <li><a href="#trunkwxruby2swigclassesGridSizeri">trunk/wxruby2/swig/classes/GridSizer.i</a></li> <li><a href="#trunkwxruby2swigclassesSizeri">trunk/wxruby2/swig/classes/Sizer.i</a></li> <li><a href="#trunkwxruby2swigclassesStaticBoxSizeri">trunk/wxruby2/swig/classes/StaticBoxSizer.i</a></li> <li><a href="#trunkwxruby2swigclassesStdDialogButtonSizeri">trunk/wxruby2/swig/classes/StdDialogButtonSizer.i</a></li> </ul> <h3>Added Paths</h3> <ul> <li><a href="#trunkwxruby2swigsharedsizersi">trunk/wxruby2/swig/shared/sizers.i</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="trunkwxruby2swigclassesBoxSizeri"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/BoxSizer.i (1032 => 1033)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/BoxSizer.i        2007-05-22 21:40:09 UTC (rev 1032) +++ trunk/wxruby2/swig/classes/BoxSizer.i        2007-05-28 19:17:14 UTC (rev 1033) </span><span class="lines">@@ -6,6 +6,12 @@ </span><span class="cx"> %module(directors="1") wxBoxSizer </span><span class="cx"> GC_MANAGE_AS_OBJECT(wxBoxSizer); </span><span class="cx"> </span><ins>+ +// shared functions for GC marking +%include "../shared/sizers.i" +%markfunc wxBoxSizer "mark_wxSizer"; + + </ins><span class="cx"> %import "include/wxObject.h" </span><span class="cx"> %import "include/wxSizer.h" </span><span class="cx"> </span></span></pre></div> <a id="trunkwxruby2swigclassesFlexGridSizeri"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/FlexGridSizer.i (1032 => 1033)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/FlexGridSizer.i        2007-05-22 21:40:09 UTC (rev 1032) +++ trunk/wxruby2/swig/classes/FlexGridSizer.i        2007-05-28 19:17:14 UTC (rev 1033) </span><span class="lines">@@ -12,6 +12,11 @@ </span><span class="cx"> %ignore wxFlexGridSizer::SetNonFlexibleDirection; </span><span class="cx"> %ignore wxFlexGridSizer::GetNonFlexibleGrowMode; </span><span class="cx"> %ignore wxFlexGridSizer::SetNonFlexibleGrowMode; </span><ins>+ +// shared functions for GC marking +%include "../shared/sizers.i" +%markfunc wxBoxSizer "mark_wxSizer"; + </ins><span class="cx"> </span><span class="cx"> </span><span class="cx"> %import "include/wxObject.h" </span></span></pre></div> <a id="trunkwxruby2swigclassesGridBagSizeri"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/GridBagSizer.i (1032 => 1033)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/GridBagSizer.i        2007-05-22 21:40:09 UTC (rev 1032) +++ trunk/wxruby2/swig/classes/GridBagSizer.i        2007-05-28 19:17:14 UTC (rev 1033) </span><span class="lines">@@ -10,6 +10,11 @@ </span><span class="cx"> #include <wx/gbsizer.h> </span><span class="cx"> %} </span><span class="cx"> </span><ins>+// shared functions for GC marking +%include "../shared/sizers.i" +%markfunc wxBoxSizer "mark_wxSizer"; + + </ins><span class="cx"> // ignore these for now - are they useful? </span><span class="cx"> // require GBSizerItem to be wrapped </span><span class="cx"> %ignore wxGridBagSizer::FindItemWithData; </span></span></pre></div> <a id="trunkwxruby2swigclassesGridSizeri"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/GridSizer.i (1032 => 1033)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/GridSizer.i        2007-05-22 21:40:09 UTC (rev 1032) +++ trunk/wxruby2/swig/classes/GridSizer.i        2007-05-28 19:17:14 UTC (rev 1033) </span><span class="lines">@@ -6,6 +6,11 @@ </span><span class="cx"> %module(directors="1") wxGridSizer </span><span class="cx"> GC_MANAGE_AS_OBJECT(wxGridSizer); </span><span class="cx"> </span><ins>+// shared functions for GC marking +%include "../shared/sizers.i" +%markfunc wxBoxSizer "mark_wxSizer"; + + </ins><span class="cx"> %import "include/wxObject.h" </span><span class="cx"> %import "include/wxSizer.h" </span><span class="cx"> </span></span></pre></div> <a id="trunkwxruby2swigclassesSizeri"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/Sizer.i (1032 => 1033)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/Sizer.i        2007-05-22 21:40:09 UTC (rev 1032) +++ trunk/wxruby2/swig/classes/Sizer.i        2007-05-28 19:17:14 UTC (rev 1033) </span><span class="lines">@@ -6,13 +6,13 @@ </span><span class="cx"> %module(directors="1") wxSizer </span><span class="cx"> GC_MANAGE_AS_OBJECT(wxSizer); </span><span class="cx"> </span><ins>+%feature("nodirector") wxSizer::CalcMin; </ins><span class="cx"> %ignore wxSizer::IsShown; </span><span class="cx"> </span><del>-%feature("nodirector") wxSizer::CalcMin; </del><ins>+// shared functions for GC marking +%include "../shared/sizers.i" +%markfunc wxSizer "mark_wxSizer"; </ins><span class="cx"> </span><del>-// Any nested sizers passed to Add() in are owned by C++, not GC''d by Ruby -%apply SWIGTYPE *DISOWN { wxSizer* sizer }; - </del><span class="cx"> %import "include/wxObject.h" </span><span class="cx"> </span><span class="cx"> %include "include/wxSizer.h" </span></span></pre></div> <a id="trunkwxruby2swigclassesStaticBoxSizeri"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/StaticBoxSizer.i (1032 => 1033)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/StaticBoxSizer.i        2007-05-22 21:40:09 UTC (rev 1032) +++ trunk/wxruby2/swig/classes/StaticBoxSizer.i        2007-05-28 19:17:14 UTC (rev 1033) </span><span class="lines">@@ -6,6 +6,10 @@ </span><span class="cx"> %module(directors="1") wxStaticBoxSizer </span><span class="cx"> GC_MANAGE_AS_OBJECT(wxStaticBoxSizer); </span><span class="cx"> </span><ins>+// shared functions for GC marking +%include "../shared/sizers.i" +%markfunc wxBoxSizer "mark_wxSizer"; + </ins><span class="cx"> %import "include/wxObject.h" </span><span class="cx"> %import "include/wxSizer.h" </span><span class="cx"> %import "include/wxBoxSizer.h" </span></span></pre></div> <a id="trunkwxruby2swigclassesStdDialogButtonSizeri"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/StdDialogButtonSizer.i (1032 => 1033)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/StdDialogButtonSizer.i        2007-05-22 21:40:09 UTC (rev 1032) +++ trunk/wxruby2/swig/classes/StdDialogButtonSizer.i        2007-05-28 19:17:14 UTC (rev 1033) </span><span class="lines">@@ -6,6 +6,12 @@ </span><span class="cx"> %module(directors="1") wxStdDialogButtonSizer </span><span class="cx"> GC_MANAGE_AS_OBJECT(wxStdDialogButtonSizer); </span><span class="cx"> </span><ins>+ +// shared functions for GC marking +%include "../shared/sizers.i" +%markfunc wxBoxSizer "mark_wxSizer"; + + </ins><span class="cx"> %import "include/wxObject.h" </span><span class="cx"> %import "include/wxSizer.h" </span><span class="cx"> %import "include/wxBoxSizer.h" </span></span></pre></div> <a id="trunkwxruby2swigsharedsizersi"></a> <div class="addfile"><h4>Added: trunk/wxruby2/swig/shared/sizers.i (0 => 1033)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/shared/sizers.i         (rev 0) +++ trunk/wxruby2/swig/shared/sizers.i        2007-05-28 19:17:14 UTC (rev 1033) </span><span class="lines">@@ -0,0 +1,31 @@ </span><ins>+ + +// Any nested sizers passed to Add() in are owned by C++, not GC''d by Ruby +%apply SWIGTYPE *DISOWN { wxSizer* sizer }; + + +// Whilst sizers that are directly managing Windows will be marked, +// those that are contained within other sizers need to be explicitly +// handled: +%{ +static void mark_wxSizer(void *ptr) +{ + wxSizer* wx_sizer = (wxSizer*)ptr; + wxSizerItemList& children = wx_sizer->GetChildren(); + + // Mark each menu in the menubar in turn + for ( wxwxSizerItemListNode *node = children.GetFirst(); +                node; +                node = node->GetNext() ) +        { +         wxSizerItem* item = node->GetData(); +         wxSizer* child_sizer = item->GetSizer(); +         if ( child_sizer ) +                { +                 VALUE rb_child_sizer = SWIG_RubyInstanceFor(child_sizer); +                 rb_gc_mark(rb_child_sizer); +                } +        } +} +%} + </ins></span></pre> </div> </div> </body> </html>
Maybe Matching Threads
- [1108] trunk/wxruby2/swig: Revised mem mgmt for Sizers to address more GC crashes in Sizers demo
- [1077] trunk/wxruby2/swig/classes/StaticBoxSizer.i: Avoid crash-on-exit with StatBoxSizer by removing some unnec director methods
- [1087] trunk/wxruby2/swig/classes/StaticBoxSizer.i: Fix a dopey typo introduced recently
- [1079] trunk/wxruby2/swig/classes/StaticBoxSizer.i: Fix a misnamed function accidentally added in SVN:1077
- [1032] trunk/wxruby2/swig: Preserve Sizers associated with Windows from GC; fix several sample