# Error: undefined method 'calc\_min' for #\<Wx::IdleEvent\>

**URL:** <https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323>\
**Category:** wxRuby\
**Created:** [March 31, 2009, 7:02am UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323 "2009-03-31T07:02:52Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [March 31, 2009, 7:02am UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/1 "2009-03-31T07:02:52Z")

</div>

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:in`layout’  
(eval):154:in `process_event' (eval):154:in`on\_run’  
(eval):154:in `main\_loop’

Zhimin

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [March 31, 2009, 2:58pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/2 "2009-03-31T14:58:18Z")

</div>

On Tue, Mar 31, 2009 at 1:02 AM, Zhimin Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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.

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [March 31, 2009, 9:55pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/3 "2009-03-31T21:55:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [March 31, 2009, 10:48pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/4 "2009-03-31T22:48:06Z")

</div>

On Mar 31, 2009, at 2:57 PM, Eric W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Are you using DataMapper?

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

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 1, 2009, 12:02am UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/5 "2009-04-01T00:02:17Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 1, 2009, 4:54pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/6 "2009-04-01T16:54:51Z")

</div>

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](http://rubyforge.org/projects/datamapper)

Eric R.

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [March 31, 2009, 11:12pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/7 "2009-03-31T23:12:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 2, 2009, 3:40pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/8 "2009-04-02T15:40:10Z")

</div>

On Thu, Apr 2, 2009 at 9:18 AM, Eric W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 2, 2009, 3:32pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/9 "2009-04-02T15:32:34Z")

</div>

On Wed, Apr 1, 2009 at 10:37 AM, Eric R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](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.

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 2, 2009, 7:14pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/10 "2009-04-02T19:14:47Z")

</div>

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

Eric R.

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 2, 2009, 8:15pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/11 "2009-04-02T20:15:47Z")

</div>

On Thu, Apr 2, 2009 at 1:05 PM, Eric R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 2, 2009, 5:19pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/12 "2009-04-02T17:19:49Z")

</div>

On Thu, Apr 2, 2009 at 9:21 AM, Eric W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 2, 2009, 11:17pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/13 "2009-04-02T23:17:03Z")

</div>

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 method`calc\_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

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 5, 2009, 11:18am UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/14 "2009-04-05T11:18:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 6, 2009, 7:41pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/15 "2009-04-06T19:41:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zzhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/7cd45c/32.png) [@zzhan](https://www.ruby-forum.com/u/zzhan)\
**Post date:** [April 5, 2009, 9:26pm UTC](https://www.ruby-forum.com/t/error-undefined-method-calc-min-for-wx-idleevent/164323/16 "2009-04-05T21:26:48Z")

</div>

On Sun, Apr 5, 2009 at 4:27 AM, Mario S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.
