WebDialog LocalJumpError

3 views
Skip to first unread message

Jim

unread,
Jun 14, 2007, 1:04:39 PM6/14/07
to Google SketchUp Help - Ruby ideas
What causes the LocalJumpError when trying to return, exit, break from
a WebDialog callback?

TB

unread,
Jun 14, 2007, 2:48:49 PM6/14/07
to Google SketchUp Help - Ruby ideas
Is this a javascript error or a C++ Runtime error?

Todd

Jim

unread,
Jun 15, 2007, 12:04:43 AM6/15/07
to Google SketchUp Help - Ruby ideas
Ruby error.

TB

unread,
Jun 15, 2007, 4:57:19 AM6/15/07
to Google SketchUp Help - Ruby ideas
It appears (from reading "Programming Ruby' (Second Edition - Dave
Thomas) that this is new behavior starting Ruby 1.8.

In summary, (page 358) it says this:

"A return from inside a block that's still in scope acts as a return
from that scope. A return from a block whose original context is not
longer valid raises an exception (LocalJumpError or ThreadError
depending on the context)..."

It then goes on to cite examples and offers ideas for workarounds.

Google search showed a few hits. Here's one with a workaround:

http://blog.jayfields.com/2007/03/ruby-localjumperror-workaround.html

Todd

Jim

unread,
Jun 15, 2007, 11:28:34 AM6/15/07
to Google SketchUp Help - Ruby ideas
Thanks Todd.

I found if I moved the code out of add_action_callback and into its
own method, and then called the method from add_action_callback, the
error goes away. I'd still like to better understand why, though.

Here's an example:


# OLD CODE
dialog.add_action_callback("name") {
# lots of code
}

# NEW CODE

def name(*args)
# lots of code
end

dialog.add_action_callback("name") { name() }


TB

unread,
Jun 15, 2007, 12:40:59 PM6/15/07
to Google SketchUp Help - Ruby ideas
Yeah, I can underestand that.

I'm no ruby internals expert, but it might have something to do with
the static nature of a hard coded method (your new code) versus the
dynamic nature of the code block {...} in your first method. Perhaps
the block method is structured internally in an automatic storage
manner, and jumping back from automatic storage is what now causes
this exception. (Grasping here?)

Glad you got it working. Hope my input helped.

Todd

Reply all
Reply to author
Forward
0 new messages