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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
01a68e65c05c8751d75dbf957ea4fa23?d=identicon&s=25 Zhimin Zhan (zzhan)
on 2009-03-31 07:02
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
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-03-31 14:58
(Received via mailing list)
On Tue, Mar 31, 2009 at 1:02 AM, Zhimin Zhan <lists@ruby-forum.com>
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 Will
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-03-31 21:55
(Received via mailing list)
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.
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-03-31 22:48
(Received via mailing list)
On Mar 31, 2009, at 2:57 PM, Eric Will <rakaur@malkier.net> wrote:

> Are you using DataMapper?

Seems mysql causes the same problem. I'm at a total loss.
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-03-31 23:12
(Received via mailing list)
Hi Eric

Eric Will 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
01a68e65c05c8751d75dbf957ea4fa23?d=identicon&s=25 Zhimin Zhan (zzhan)
on 2009-04-01 00:02
> 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
Fe061a5e90b738e88623292d7d2084d2?d=identicon&s=25 Eric Rubin (erubin)
on 2009-04-01 16:54
(Received via mailing list)
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 Rubin
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-04-02 15:32
(Received via mailing list)
On Wed, Apr 1, 2009 at 10:37 AM, Eric Rubin <erubin@valcom.com> 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 Rubin

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 Will
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-04-02 15:40
(Received via mailing list)
On Thu, Apr 2, 2009 at 9:18 AM, Eric Will <rakaur@malkier.net> 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 Will
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-04-02 17:19
(Received via mailing list)
On Thu, Apr 2, 2009 at 9:21 AM, Eric Will <rakaur@malkier.net> 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.
Fe061a5e90b738e88623292d7d2084d2?d=identicon&s=25 Eric Rubin (erubin)
on 2009-04-02 19:14
(Received via mailing list)
Going to DataMapper 0.9.11 solved my problem with validation under Ruby
1.9

Eric Rubin
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-04-02 20:15
(Received via mailing list)
On Thu, Apr 2, 2009 at 1:05 PM, Eric Rubin <erubin@valcom.com> wrote:
> Going to DataMapper 0.9.11 solved my problem with validation under Ruby 1.9

This didn't do anything for me.

> Eric Rubin

-- Eric Will
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-04-02 23:17
(Received via mailing list)
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
3396e4a3df8a840faec520af8555a400?d=identicon&s=25 Mario Steele (Guest)
on 2009-04-05 11:18
(Received via mailing list)
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
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-04-05 21:26
(Received via mailing list)
On Sun, Apr 5, 2009 at 4:27 AM, Mario Steele <mario@ruby-im.net> 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 Will
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-04-06 19:41
(Received via mailing list)
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 Will
This topic is locked and can not be replied to.