WebDialog Closes Mysteriously
-
I had to clear out my Plugins folder, but the problem went away.
I'll post if I find anything.
-
I had this problem until I made my web dialog objects global.
-
@whaat said:
I had this problem until I made my web dialog objects global.
I could totally believe thats the problem. ie Ruby (correctly) garbage collects when it goes out of scope.
-
Yes, but the problem goes away if I clear the Plugins folder, and load only this code.
I don't understand how the scope is the reason. If that were so, wouldn't many other plugins go out of scope and not work?
-
name clashing? search for other plugins with create_dialog, dlg.
maybe there is a conflict somewhere.or you can add plugin by plugin and see the offending one
-
@unknownuser said:
name clashing? search for other plugins with create_dialog, dlg.
maybe there is a conflict somewhere.or you can add plugin by plugin and see the offending one
Thanks for the comments.
I replaced all occurrences of "jitter" with "shake", but it still happens. I recursively grep'd through the Plugins folder for "shake", and mine is the only occurrence.
My latest custom toolbars plugin is one that causes the problem. However, it can't be Whaat's problem because no one else has this plugin yet. My toolbars plugin reads a text file, loads a file, and creates Toolbar objects.
Here's an example "command" file:
cmd = UI;;Command.new("Arc") { Sketchup.send_action "selectArcTool;" } cmd.large_icon = "../images/arc_lg.png" cmd.small_icon = "../images/arc_sm.png" cmd.tooltip = "Arc" cmd.status_bar_text = "Draw arcs" cmd.menu_text = "Arc" cmd.set_validation_proc { tool_validation_proc("ArcTool") } @cmd = cmd
and here's a simpified example of how I am loading it:
ruby_files.each do |file| load file toolbar.add_item @cmd end
See any problems here? The plugin is not ready for the public, but I can share it if anyone wants to have a look for any problems.
-
Jim: I can take a look, if you want, and see if it shows the same behaviour here
-
@unknownuser said:
Jim: I can take a look, if you want, and see if it shows the same behaviour here
I've sent the plugin in a PM, thank you.
-
@jim said:
Yes, but the problem goes away if I clear the Plugins folder, and load only this code.
I don't understand how the scope is the reason. If that were so, wouldn't many other plugins go out of scope and not work?
Sure, but in doing so you're changing the character of garbage collection.
My hunch (based on nothing) is that the schema handler stuff (ie skp:blah) just expects the dialog to stay in scope although its an asynchronous process. Your code exits the block and does other stuff, 256 opcodes later (yes, I saw it in the Ruby source code - ouch!) the GC kicks in and sweeps it away. The javascript side then gets its knickers in a twist because the Ruby side dialog that was consuming data has disappeared.
Adam
-
Thanks for the comments, everyone; and especially to TBD.
It seems obvious now, but the variable that is referencing the dialog is local to the method. When the method is finished, so is everything else in the same scope. And so sooner or later the variable will get cleaned up by Ruby's garbage collection, and the dialog "mysteriously" goes away. So for the code I posted, a global variable will solve the problem. You could also use an instance variable.
Please, correct any mis-understandings I have about what's happening.
Advertisement