nobody at rubyforge.org
2007-Mar-19 12:22 UTC
[Wxruby-development] [898] branches/wxruby2/wxwidgets_282/swig/classes/App.i: Fix init of stock objects for Wx2.8 - was causing infinite loop +crash on OS X
<!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>[898] branches/wxruby2/wxwidgets_282/swig/classes/App.i: Fix init of stock objects for Wx2.8 - was causing infinite loop +crash on OS X</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>898</dd> <dt>Author</dt> <dd>brokentoy</dd> <dt>Date</dt> <dd>2007-03-19 08:22:14 -0400 (Mon, 19 Mar 2007)</dd> </dl> <h3>Log Message</h3> <pre>Fix init of stock objects for Wx2.8 - was causing infinite loop +crash on OS X</pre> <h3>Modified Paths</h3> <ul> <li><a href="#brancheswxruby2wxwidgets_282swigclassesAppi">branches/wxruby2/wxwidgets_282/swig/classes/App.i</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="brancheswxruby2wxwidgets_282swigclassesAppi"></a> <div class="modfile"><h4>Modified: branches/wxruby2/wxwidgets_282/swig/classes/App.i (897 => 898)</h4> <pre class="diff"><span> <span class="info">--- branches/wxruby2/wxwidgets_282/swig/classes/App.i        2007-03-18 10:46:56 UTC (rev 897) +++ branches/wxruby2/wxwidgets_282/swig/classes/App.i        2007-03-19 12:22:14 UTC (rev 898) </span><span class="lines">@@ -43,6 +43,8 @@ </span><span class="cx"> #endif         </span><span class="cx"> } </span><span class="cx"> </span><ins>+ // This is the method run when main_loop is called in Ruby + // wxEntry calls the C++ App::OnInit method </ins><span class="cx"> int main_loop() </span><span class="cx"> { </span><span class="cx"> static int argc = 1; </span><span class="lines">@@ -63,8 +65,6 @@ </span><span class="cx">                 wxEntry(argc, argv); </span><span class="cx"> #endif </span><span class="cx"> </span><del>- - </del><span class="cx"> #ifdef __WXDEBUG__ </span><span class="cx"> printf("returned from wxEntry...\n"); </span><span class="cx"> #endif         </span><span class="lines">@@ -75,20 +75,20 @@ </span><span class="cx"> return 0; </span><span class="cx"> } </span><span class="cx"> </span><del>- virtual bool OnInitGui() </del><ins>+ // This method initializes the stock objects (Pens, Brushes, Fonts) + // before yielding to ruby by calling the App''s on_init method. + // Note that as of wxWidget 2.8, the stock fonts in particular cannot + // be initialized any earlier than this without crashing + bool OnInit() </ins><span class="cx"> { </span><del>-#ifdef __WXDEBUG__ - printf("OnInitGui before\n"); -#endif         - bool result = wxApp::OnInitGui(); -#ifdef __WXDEBUG__         - printf("OnInitGui after\n"); -#endif         -                // Stock objects must not be instantiated before a wxApp has started -                if ( result ) -                 //                 Init_wxRubyStockObjects(); - - return result; </del><ins>+ Init_wxRubyStockObjects(); +         VALUE result = rb_funcall(wxRubyApp::app_ptr, rb_intern("on_init"), 0, NULL); +         if ( result == Qfalse || result == Qnil ) { +                return false; +         } +          else { +                return true; +         } </ins><span class="cx"> } </span><span class="cx"> </span><span class="cx"> virtual int OnExit() </span><span class="lines">@@ -123,13 +123,6 @@ </span><span class="cx">                 printf("ASSERT fired\n"); </span><span class="cx">         } </span><span class="cx"> </span><del>-bool Initialize(int& argc, wxChar **argv) -        { -                bool result = wxApp::Initialize(argc, argv); -                return result; -        } - - </del><span class="cx"> }; </span><span class="cx"> </span><span class="cx"> VALUE wxRubyApp::app_ptr = Qnil; </span><span class="lines">@@ -151,7 +144,6 @@ </span><span class="cx"> bool GetUseBestVisual() const; </span><span class="cx"> wxString GetVendorName() const; </span><span class="cx"> void ExitMainLoop() ; </span><del>- bool Initialized() ; </del><span class="cx"> int MainLoop() ; </span><span class="cx"> virtual void OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg); </span><span class="cx"> virtual int OnExit() ; </span><span class="lines">@@ -159,7 +151,7 @@ </span><span class="cx"> virtual bool OnCmdLineHelp(wxCmdLineParser& parser ) ; </span><span class="cx"> virtual bool OnCmdLineParsed(wxCmdLineParser& parser ) ; </span><span class="cx"> virtual void OnFatalException() ; </span><del>- virtual bool OnInit() ; </del><ins>+ bool OnInit() ; </ins><span class="cx"> virtual void OnInitCmdLine(wxCmdLineParser& parser ) ; </span><span class="cx"> ; </span><span class="cx"> bool ProcessMessage(WXMSG * msg ) ; </span><span class="lines">@@ -176,7 +168,5 @@ </span><span class="cx"> void SetVendorName(const wxString& name ) ; </span><span class="cx"> void SetUseBestVisual(bool flag ) ; </span><span class="cx"> bool Yield(bool onlyIfNeeded = false) ; </span><del>- - int main_loop(); -                 </del><ins>+ int main_loop(); </ins><span class="cx"> }; </span></span></pre> </div> </div> </body> </html>
Maybe Matching Threads
- [934] branches/wxruby2/wxwidgets_282: Rename OnAssert to OnAssertFailure, reflecting wx 2.8 API
- [1022] trunk/wxruby2/swig/classes/App.i: Memory mgmt: use Wx::App to mark still-alive Windows, set up Wx::THE_APP const
- [926] branches/wxruby2/wxwidgets_282: Update Dialog wx2.6 -> wx2.8 API, remove deprecations and cruft, update doc
- [804] trunk/wxruby2/swig: Initialise stock colours (eg Wx::RED), pens and brushes when wxruby2 is
- [826] trunk/wxruby2/swig: Move RubyStockObjects back to App.i to avoid lots of error msg on GTK