Error: undefined method 'calc_min' for #<Wx::IdleEvent>

Hi,

I occasionally had the following error when application in idle state.

Error: undefined method ‘calc_min’ for #Wx::IdleEvent:0xb115e44
OS: WXMSW
Ruby Version: 1.8.6
wxRuby 2.0.0
Backtrace:
(eval):154:in calc_min' (eval):154:inlayout’
(eval):154:in process_event' (eval):154:inon_run’
(eval):154:in `main_loop’

Zhimin

On Tue, Mar 31, 2009 at 1:02 AM, Zhimin Z. [email protected]
wrote:

Hi,

I occasionally had the following error when application in idle state.

Error: undefined method ‘calc_min’ for #Wx::IdleEvent:0xb115e44

I’ve been having a related problem, and I’ve sent Alex some code to
reproduce. Mine happens when show()'ing a certain Frame, and I can’t
track it down. Only happens on 1.9 for me, though.

– Eric W.

Are you using DataMapper?

I’ve tracked this as my issue. I don’t know what’s wrong exactly, but
after using DM to pull out a large amount of data I get this. I think
it’s destroying the heap or something, somehow. It only happens in 1.9
for me. It’s so odd. I’m going to have to fall back to just using the
mysql module to pull the data itself, then use DM to objectify them
when I need them.

It’s definitely DM, but I couldn’t find a rhyme or reason to any of
the problems. It changes every time, and sometimes works fine. It has
something to do with GC as well, because when I fiddle with the GC
settings it works a lot better, but ultimately crashes anyway.

On Mar 31, 2009, at 2:57 PM, Eric W. [email protected] wrote:

Are you using DataMapper?

Seems mysql causes the same problem. I’m at a total loss.

Are you using DataMapper?

My app uses Sqlite3.

The error happened several times, usually when trying to go back the app
after leaving app idle for while.

Ruby 1.8.6 p114
wxRuby 2.0.0 on Windows XP

Zhimin

DataMapper just (Mar 30) released 0.9.11, which fixes some problems with
Ruby 1.9, especially in data validation. I haven’t tried it yet, but
I’m
about to…

http://rubyforge.org/projects/datamapper

Eric R.

Hi Eric

Eric W. wrote:

the problems. It changes every time, and sometimes works fine. It has
something to do with GC as well, because when I fiddle with the GC
settings it works a lot better, but ultimately crashes anyway.

Thanks for the follow-up. It could indeed be a bug in another extension
or in the ruby interpreter itself. Or it could be a bad interaction
between wxRuby and something else. The reason I say the latter is that
wxRuby shouldn’t be calling a Sizer method (calc_min) on an object
without being sure that that object is indeed a Wx::Sizer.

alex

On Thu, Apr 2, 2009 at 9:18 AM, Eric W. [email protected] wrote:

I’ll try the new version. I also have plans to mess with the controls
in the window, then try it without having DM required at all, and I
guess if I have to, rewrite the entire window.

Yeah, that didn’t work. Same thing happens on 1.9, and now 1.8 cores
the interpreter. Superb.

– Eric W.

On Wed, Apr 1, 2009 at 10:37 AM, Eric R. [email protected] wrote:

DataMapper just (Mar 30) released 0.9.11, which fixes some problems with
Ruby 1.9, especially in data validation. I haven’t tried it yet, but I’m
about to…

http://rubyforge.org/projects/datamapper

Eric R.

I’ll try the new version. I also have plans to mess with the controls
in the window, then try it without having DM required at all, and I
guess if I have to, rewrite the entire window.

– Eric W.

Going to DataMapper 0.9.11 solved my problem with validation under Ruby
1.9

Eric R.

On Thu, Apr 2, 2009 at 1:05 PM, Eric R. [email protected] wrote:

Going to DataMapper 0.9.11 solved my problem with validation under Ruby 1.9

This didn’t do anything for me.

Eric R.

– Eric W.

On Thu, Apr 2, 2009 at 9:21 AM, Eric W. [email protected] wrote:

Yeah, that didn’t work. Same thing happens on 1.9, and now 1.8 cores
the interpreter. Superb.

It’s now spontaneously started giving me a calc_min error on an older
program that I haven’t changed in ages. Was there a semi-recent wxRuby
update? I can’t think of any reason other than something wonky with Wx
now. This older program doesn’t use DM at all.

I tried downgrading to wxRuby 1.9.5, and now I get this:

/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:195:
[BUG] object allocation during garbage collection phase
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]

Aborted

Using 2.0.0 on 1.8:

/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:31:in
calc_min': undefined methodcalc_min’ for “FacilityNumber”:String
(NoMethodError)

[…]

So, I don’t know what exactly is going on, but I think it somehow
relates to garbage collection. When I try turning it off and/or toying
with it in other ways it crashes in different ways. I’m still not
ultimately sure what’s going on, but there’s obviously some way wxRuby
is involved.

I don’t even have to populate the ListCtrl with the data, simply
pulling it from the DB manages to do the calc_min() crash. I don’t get
how wxRuby is even getting at this stuff. Does it do some sort of
introspection/reflection? I’m simply asking the DB for the data, and
iterating over it. Simply the act of iterating over it, even if I do
nothing more than an empty loop, kills me.

I’m going nuts, here.

– Eric

Firstly, wxRuby 1.9.5 was built specifically for Ruby 1.8.6 p100ish,
around
that area, so with 1.8.7 p72, there are some major changes to the way
memory
is handled, and there by, it may be difficult to use older version of
wxRuby
with newer versionf of the Ruby interpreter.

Secondly, It is a Memory allocation issue. More specifically, somehow
wxRuby and Ruby are getting their objects mixed up. Every object that
you
create with wxRuby, is stored internally in the wxRuby library itself,
in an
Array if you would. This way, we can keep track of the instances of
objects, when there is re-direction.

By Re-directions, I mean when we need to get the control specifically,
for
an event that occured, we need to store this information somewhere,
where we
can look it up.

Now cause of this, somehow, wxRuby, or specifically wxWidgets is sending
an
instance of a control, that it knows to be valid, however, the event
handler
for calc_size(), which is part of Layout, that wxRuby attempts to parse,
can’t find the reference properly, and is returning some other Ruby
object
that it thinks it matched correctly. Therefore, we need to investigate
specifically on the C++ Layer, and on the SWIG Layer, why we are getting
invalid objects when it comes to Layout#calc_min.

Trust me, it’s extreemly hard to debug something like this. And to
track
down the source. It could actually be something that has nothing to do
with
the Memory tracking that we are doing, and in some other off-hand code
that
we are using to create objects. Simply put, we don’t know, but we are
researching the problem.

Please be patient with us.

thanks,

Mario

This is happening in my EquipmentFinderWindow which is a Wx::Frame. I
realize that this doesn’t fix anything, but it “hides” the problem and
the window works normally afterward:

    begin

        show

    rescue NoMethodError => e

        raise unless e =~ /calc_min/

        EquipmentFinderWindow.new

    end

I realize it’s not a real fix, and it’s only probably messing stuff up
more, but it works, for now…

– Eric W.

On Sun, Apr 5, 2009 at 4:27 AM, Mario S. [email protected] wrote:

Trust me, it’s extreemly hard to debug something like this. And to track
down the source. It could actually be something that has nothing to do with
the Memory tracking that we are doing, and in some other off-hand code that
we are using to create objects. Simply put, we don’t know, but we are
researching the problem.

Please be patient with us.

Trust me, I know. I used to code in straight C, and I would get
difficult problems like this from time to time. I appreciate that you
are looking into it. If it helps, it seems to happen less often on
1.8. Sometimes it works fine, sometimes it gives me the calc_min()
error. It ALWAYS gives me the calc_min() on 1.9.

thanks,

Mario

– Eric W.