New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Menu#add_submenu failure #777
Comments
Is this happening only on Windows by any chance? And is it always in scenarios where you have an instance variable? Are you sharing the menu reference cross extensions? |
On Windows only. And yes, the menu object is in an instance variable But this seems to happen randomly. |
I've seem something similar when creating menus from the Ruby Console:
But separately:
Are you sharing the menu references across multiple extensions? Maybe... if we see the same scenario as in the Ruby Console if; an extension is installed? (The menu ref might no longer work until you restart?) Or if, something delays some code execution to take it out of the startup loop, a timer for instance...? |
It looks like it is the issue with the persistence of menu handles in Windows, already reported. All I try to achieve is to group the menu entries of all my plugins under Tools / Fredo6 Collection. Normally it works, but apparently there may be some cases now where it does not due to this issue of menu handle persistence. I would suggest that the menu handling is reviewed to provide a working API to do this grouping by author that many users prefer, in order not to have the Extensions menus and other SketchUp top menus crowded with plugin menu entries when they have many installed. We need a solid framework, and also a way to test whether a menu has already been created. Today there is no method, since |
We are in the process of replacing the tech for the UI. So lots of UI/UX related items on our plate coming up. I've tagged this issue |
Ie .. we've brought this up in the past (about using slash ['/'] characters) that are already used on Mac in the menus. It already causes issues with confused shortcuts, etc. There is likely no check to prevent slashes in menu name (submenus or items) so trying to use menu path strings may be problematic going forward. (Unless some new rule is implemented and embedded slashes are replaced with some other character by the API methods that create submenus, menu items and It would be easier and more robust as: tools = UI.menu('Tools')
submenu = tools.get_submenu('Fredo6 Collection')
submenu = tools.add_submenu('Fredo6 Collection') unless submenu ... or ... submenu = UI.menu('Tools').get_submenu('Fredo6 Collection', create: true) The Also a boolean query method could be useful ... UI.menu('Tools').has_submenu?('Fredo6 Collection') Rounding out the features, a method to test whether an item or command has been added ... if UI.menu('Tools')&.get_submenu('Fredo6 Collection')&.has_item?('Round Corner') I'm not sure if a ADD: Also it would be nice to test if the menu currently has a separator at the bottom so as not to create double separators.
I agree, this should return Also, the same Ruby object (and ID) should be retrieved each time a menu handle is requested by the API method call(s). (Currently we get a different object each time on Windows.) REF: |
Oh, I thought of another method and that is a test what type of object is at a particular index in a menu (ie, submenu, separator or menu command.) if UI.menu('Tools').type_at(12) == MENU_SUBMENU Could also use A negative index counts from the bottom, ie |
Logged as: SKEXT-3903 |
Putting traces in my code, I found occurrences where
Menu#add_submenu
fails (i.e. returnnil
), although the argument are valid.The traces shows that
@su_menu.add_submenu(@menu_name)
returnsnil
withThis happens rarely, a few users, and randomly, that is, not necessarily TopoShaper. Furthermore, sers getting the problem may have it working fine when reinstalling the plugins or Sketchup.
Could someone in the Trimble Extensibility team have a look at the
Menu#add_submenu
method and check under which conditions the method could returnnil
.The text was updated successfully, but these errors were encountered: