On Mon, 2006-07-24 at 21:31 +0100, Alex Fenton wrote:> Hi
>
> Attached a small patch to Window.i which prevents it crashing when
> find_window_by_name, find_window_by_id or find_window_by_label should
> return nil.
I''m glad to see this fixed, but I haven''t applied this patch
because I
don''t think this is the best way to deal with it.
Instead of surrounding every get_ruby_object call with an if(obj), why
not just change get_ruby_object to detect a null object and immediately
return Qnil? Not only would it be less code, but it would also protect
us in the future if anyone forgot to check obj before calling
get_ruby_object.
Can you submit a new patch taking that approach?
Thanks,
Kevin
Here''a a fragment of the submitted patch, for reference:
> {
> VALUE returnVal = Qnil;
> wxObject* obj = wxWindow::FindWindowById(id,parent);
> + if (obj)
> + {
> returnVal = get_ruby_object(obj);
> + }