Forum: wxRuby Patch: crash during GC when using combo, listbox.

E7f3cbcb69beec85643d1ecc54121460?d=identicon&s=25 David Beswick (davidbeswick)
on 2013-04-16 02:06
(Received via mailing list)
Hi all, I feel like I may have written about this before, apologies if
so.

I recently started getting "object allocation during garbage collection
phase" with wxruby on linux. I traced the problem to GetCount() being
called on list and combo boxes during the GC's mark phase. Since the
GetCount() method has a director, the C++ call triggers a ruby call that
then allocates a ruby object to store the result, triggering the error.

This patch just disables the director on GetCount(), but that also means
that this method can't be overriden in Ruby.

I'm also not sure why this just started happening to me. I did shuffle
around some code that may have caused a GC where there wasn't one
before,
but surely every GC should trigger this problem if my description of the
cause is right?


Index: swig/shared/control_with_items.i
===================================================================
--- swig/shared/control_with_items.i    (revision 2115)
+++ swig/shared/control_with_items.i    (working copy)
@@ -13,6 +13,7 @@
 %feature("nodirector") *::GetClientObject(int n) const;
 %ignore *::SetClientObject(int  n, wxClientData * data);
 %feature("nodirector") *::SetClientObject(int  n, wxClientData * data);
+%feature("nodirector") *::GetCount() const;

 %{
   extern swig_class cWxControlWithItems;
This topic is locked and can not be replied to.