Hello all. This gets past the problem in bigdemo where it won''t start the application at all. That was where it was overflowing the stack on get_label. Roy _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
On Thu, 2006-03-30 at 00:31 -0500, Roy Sutton wrote:> Hello all. This gets past the problem in bigdemo where it won''t start > the application at all. That was where it was overflowing the stack on > get_label.This one is driving me INSANE. When I made this same change, my compiler (gcc 4.0.2 I believe) complains that wxControl is not a base class of wxTreeCtrl. But *it is*. I have a couple things left to try, but at this point I am completely confused. It knows that wxWindow is an ancestor, but not wxControlBase or wxControl. ARGH! Has anyone else tried this patch, and has it worked? Kevin
On Sun, 2006-04-09 at 22:33 -0400, Kevin Smith wrote:> This one is driving me INSANE. When I made this same change, my compiler > (gcc 4.0.2 I believe) complains that wxControl is not a base class of > wxTreeCtrl. But *it is*. I have a couple things left to try, but at this > point I am completely confused. It knows that wxWindow is an ancestor, > but not wxControlBase or wxControl. ARGH!Quick update: I haven''t solved it, but at least I know mostly what is going on. With my wx installation, for whatever reason, wxTreeCtrl inherits from wxGenericTreeCtrl, which inherits from wxScrolledWindow. So it bypasses wxControl, which means our classes/include/wxTreeCtrl.h is incorrect. Hopefully later this week I''ll be able to go back and fix this, somehow. Hopefully in a way that will work on all platforms. By the way, the tool I used to figure this out was to add -E to the compiler flags. That sends the preprocessor results to the .o file instead of actual object code. With that, I was able to see the actual class hierarchy, rather than the one that I thought I was seeing when I looked at the wx header files. Kevin
Glad to see you''re getting to the bottom of this. I imagine this won''t be the last time different hierarchies will bite us in the butt. I''m taking a bit of time to get more familiar with Swig so that I won''t feel so lost when we get into the object tracking portion. Kevin Smith wrote:> On Sun, 2006-04-09 at 22:33 -0400, Kevin Smith wrote: > >> This one is driving me INSANE. When I made this same change, my compiler >> (gcc 4.0.2 I believe) complains that wxControl is not a base class of >> wxTreeCtrl. But *it is*. I have a couple things left to try, but at this >> point I am completely confused. It knows that wxWindow is an ancestor, >> but not wxControlBase or wxControl. ARGH! >> > > Quick update: I haven''t solved it, but at least I know mostly what is > going on. With my wx installation, for whatever reason, wxTreeCtrl > inherits from wxGenericTreeCtrl, which inherits from wxScrolledWindow. > So it bypasses wxControl, which means our classes/include/wxTreeCtrl.h > is incorrect. > > Hopefully later this week I''ll be able to go back and fix this, somehow. > Hopefully in a way that will work on all platforms. > > By the way, the tool I used to figure this out was to add -E to the > compiler flags. That sends the preprocessor results to the .o file > instead of actual object code. With that, I was able to see the actual > class hierarchy, rather than the one that I thought I was seeing when I > looked at the wx header files. > > Kevin > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > > >
Kevin Smith wrote:> Has anyone else tried this patch, and has it worked? >I tried it, and had to back out to get it to wxruby2 to compile. With it applied, on OS X I get the output below: alex core_name: TreeCtrl g++ -c -I/usr/local/lib/wx/include/mac-unicode-release-static-2.6 -I/usr/local/include/wx-2.6 -D__WXMAC__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DNO_GCC_PRAGMA -O2 -pipe -fno-common -x objective-c++ -I /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/bin -I /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib -I /Applications/Emacs.app/Contents/Resources/lib/ruby/site_ruby -I /usr/local/lib/ruby/site_ruby/1.8 -I /usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin7.9.0 -I /usr/local/lib/ruby/site_ruby -I /usr/local/lib/ruby/1.8 -I /usr/local/lib/ruby/1.8/powerpc-darwin7.9.0 -I . -o obj/TreeCtrl.o src/TreeCtrl.cpp src/TreeCtrl.cpp: In member function `virtual wxString SwigDirector_wxTreeCtrl::GetLabel()'': src/TreeCtrl.cpp:2904: error: cannot call member function `virtual wxString wxWindowBase::GetLabel() const'' without object src/TreeCtrl.cpp: In member function `virtual void SwigDirector_wxTreeCtrl::SetLabel(const wxString&)'': src/TreeCtrl.cpp:3419: error: cannot call member function `virtual void wxControlBase::SetLabel(const wxString&)'' without object rake aborted!
Kevin Smith
2006-Apr-12 23:48 UTC
[Wxruby-users] wxTreeCtrl has different parents on different platforms (was: Patch for wxControl.h)
Thanks Alex. That''s the same error I have seen. I think I know how to fix it, but it''s not very pretty. Right now, there''s a C++ class (wxTreeCtrl) which inherits from either wxControl or wxGenericTreeCtrl, depending on platform. Thanks to SWIG directors, we are creating a DirectorTreeCtrl (not the real name, but let''s pretend it is) which inherits from wxTreeCtrl. The problem comes in when there are virtual methods in an ancestor that are not implemented in the bottom class. For example, wxWindow defines a virtual getLabel method which is overridden in wxControl. It is critical that calls to DirectorTreeCtrl get forwarded to the correct ancestor method, which ends up in the generated C++ file as something like wxControl::GetLabel(). At swig-time, we would need to alter the class hierarchy, but that''s declared in the swig/classes/include/*.h files, so it''s hard to change them. My workaround (partially shown to maybe work) is to do what we did with wxApp, and insert a new C++ class into the hierarchy within the .i file. In TreeCtrl.i we would declare a RubyTreeCtrl class that inherits from wxTreeCtrl. It would implement any virtual methods in the ancestors, but the code body for each would be to just delegate to wxTreeCtrl::Method(). Then, we would tell SWIG to wrap RubyTreeCtrl (instead of wxTreeCtrl), and we would also rename the result as TreeCtrl (instead of RubyTreeCtrl). Yuck. Cross-platform stuff is messy. Hopefully I''ll have more time this weekend to implement what I''ve described here. Kevin On Wed, 2006-04-12 at 12:46 +0100, Alex Fenton wrote:> Kevin Smith wrote: > > Has anyone else tried this patch, and has it worked? > > > I tried it, and had to back out to get it to wxruby2 to compile. > > With it applied, on OS X I get the output below: > > alex > > > core_name: TreeCtrl > g++ -c -I/usr/local/lib/wx/include/mac-unicode-release-static-2.6 > -I/usr/local/include/wx-2.6 -D__WXMAC__ -D_FILE_OFFSET_BITS=64 > -D_LARGE_FILES -DNO_GCC_PRAGMA -O2 -pipe -fno-common -x objective-c++ > -I /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/bin -I > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib -I > /Applications/Emacs.app/Contents/Resources/lib/ruby/site_ruby -I > /usr/local/lib/ruby/site_ruby/1.8 -I > /usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin7.9.0 -I > /usr/local/lib/ruby/site_ruby -I /usr/local/lib/ruby/1.8 -I > /usr/local/lib/ruby/1.8/powerpc-darwin7.9.0 -I . -o obj/TreeCtrl.o > src/TreeCtrl.cpp > src/TreeCtrl.cpp: In member function `virtual wxString > SwigDirector_wxTreeCtrl::GetLabel()'': > src/TreeCtrl.cpp:2904: error: cannot call member function `virtual wxString > wxWindowBase::GetLabel() const'' without object > src/TreeCtrl.cpp: In member function `virtual void > SwigDirector_wxTreeCtrl::SetLabel(const wxString&)'': > src/TreeCtrl.cpp:3419: error: cannot call member function `virtual void > wxControlBase::SetLabel(const wxString&)'' without object > rake aborted! > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users