sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Crazy problem with Right Click

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    53 Posts 14 Posters 11.5k Views 14 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      Here's a little hack I made. It intercepts all the setter methods and prints the arguments to the console. Named "_0.rb" to make it load first. (or does underscore make it load last...?)

      For some reason it is not overriding the initialize method.

      But I do intercept the setter methods. On my home machine I get some output every time I right click:
      tooltip: Scaling with orientation of scaling box tooltip: Tapering with orientation of scaling box tooltip: Planar Shearing with orientation of scaling box tooltip: Planar Shearing by selection of plane and angle tooltip: Stretching with orientation of scaling box tooltip: Twisting with orientation of scaling box tooltip: Rotation with orientation of scaling box tooltip: Rotation by selection of plane and angle tooltip: Radial Bending by selection of plane and angle tooltip: Make Groups and Components Unique

      And when I do this line for every right click:
      c=[]; ObjectSpace.each_object(UI::Command) {|x| c << x }
      the count goes up by 10 - one for each tooptip.

      So in my case, even though I'm not catching the new method, it does appear that I've accounted for every leak. There might be other plugins that does not set any other methods when it creates a new Command object, so I'm not sure how to catch that since I can't hook into initialize.

      As for the tooltips, they are from FredoScale, right?


      _0.rb

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • jeff hammondJ Offline
        jeff hammond
        last edited by

        yes..

        drew a rectangle then started right-clicking repeatedly on its face.. (didn't do anything else other than those two steps.. no left-clicking,selecting, or moving the mouse pointer etc.)

        dotdotdot

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          @unknownuser said:

          yes..

          drew a rectangle then started right-clicking repeatedly on its face.. (didn't do anything else other than those two steps.. no left-clicking,selecting, or moving the mouse pointer)

          You must be charmed.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • jeff hammondJ Offline
            jeff hammond
            last edited by

            @thomthom said:

            You must be charmed.

            ha..
            but like i said earlier, i've never seen a mac user state this problem.. maybe this is one area where windows and osx are different with SU?

            dotdotdot

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Ah, you're on an apple. So you said. And so it says in your profile.
              It's late. G'night! 😉

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • EarthMoverE Offline
                EarthMover
                last edited by

                I've been able to reproduce my right click issues with consistency. I've narrowed down the problem to exploding groups and it seems to occur when I use my keyboard shortcut specifically.

                If someone could try and reproduce my results -

                1. Open new sketchup
                2. Make a Box
                3. Use keyboard shortcut to make the box a group
                4. Use keyboard shortcut to explode box
                5. Repeat step 3 & 4 - 15 times
                6. Check the right click menu during 5 more group & explodes

                I've tested the above 5 times in new SU sessions and everytime I get the same results. Right click menu goes gray between 15-20 group & explodes via keyboard shortcut.

                Interestingly I also tested doing 20 right click group and explodes and the menu didn't gray out, however after doing just one group and explode with the keyboard shortcut, my menu immediately went gray.

                Test with Shortcuts - http://www.screencast.com/t/MTVkNDBi
                Test with Right click Group & Explode - http://www.screencast.com/t/ZDFiMDRmM

                3D Artist at Clearstory 3D Imaging
                Guide Tool at Winning With Sketchup
                Content Creator at Skapeup

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by

                  @jhauswirth said:

                  The problem is Ruby scripts are calling-
                  UI::Command.new
                  and not attaching the new command to a menu item.

                  Correct, we are not typically attaching Commands to menus because Menu.add_item will accept a block of code as well as a Command. So unless a Toolbar is also being created, it is typical to just pass the name of a method to Menu.add_item:

                  def method_name
                    # do sometrhing
                  end
                  menu = UI.menu.add_item("Menu Text") { method_name }
                  

                  When a Toolbar is being used, we are required to create a Command becuase Toolbar.add_item only accepts a Command. So when there is a Toolbar already being used, it is easy to add the same Command to a menu since it is already created.

                  I think it is also not typical to create a new Command when adding a context menu. Are we sure SketchUp (Ruby) is not promoting code blocks into Commands? (Is that even possible? 😕 )

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    jhauswirth
                    last edited by

                    @unknownuser said:

                    interesting turn of events..
                    i've read a lot of these right-click posts and thought they were something to do with windows because i've never experienced the problem or heard of another mac user with the problem.
                    sounds like it should affect mac users as well then.. maybe none of the mac users here have the trouble ruby installed?
                    must be one of those windows specific exporters or something?

                    [edit] hmm.. well, except for the fact that it's been reproducible without using plugins at all ❓

                    There was another bug regarding recycling menu IDs. This was caused by the app not being able to execute OnIdle because the context menu was constantly being popped up. I didn't mention this issue because once OnIdle got a chance to do its business all the menu items came back to life. All the issues I've seen would be Windows only.

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      jhauswirth
                      last edited by

                      I have a ton of Ruby scripts installed and the only one I see creating new command IDs is-
                      ZLoader__FredoScale.rb

                      ie- FredoScale

                      If anyone that is having menu troubles and has this script, can you try removing the script and see if it helps?

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        @jhauswirth said:

                        I have a ton of Ruby scripts installed and the only one I see creating new command IDs is-
                        ZLoader__FredoScale.rb

                        ie- FredoScale

                        If anyone that is having menu troubles and has this script, can you try removing the script and see if it helps?

                        After I disable it from under Extensions and restart SU, then the UI::Command instance count stay fixed.

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          That was when I right clicked on a component.

                          It occured to me to try different entities, as plugins add different items depending on what's right clicked.
                          When I right click components things are fine.
                          So are Faces.
                          But edges are showing an increase in one Command per right click.

                          Thomas Thomassen — SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            My Selection Toys plugin uses my TT_Lib library. It has a Menu and Toolbar manager which let the user turn on and off UI items. It uses UI::Command for all items.
                            However, it does not make the UI:Command instance count increase upon each right click.

                            I create a cached list of UI:Command object upon loading the script, and the context menus are being fed these every time it needs.
                            So do I understand this correct that creating UI::Commands within the context menu handler is bad?
                            But creating the UI::Command objects before and storing in a variable for reuse is ok?

                            UI::Command objects are never garbage collected?
                            And the limit is fixed exactly at 1000?
                            But this is something that occurs on Windows? Does it not occur on OSX because the UI::Command objects are released, or because it does not have this limit?

                            I also then would imagine that Tools with custom menu also works like this.

                            Thomas Thomassen — SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              And does this mean there is a upper limit to the amount of menus?
                              Say if we use only menus without the UI::Command object, will that trigger this bug?
                              Will a large amount of toolbar buttons cause this? Even if the toolbars are off?

                              Thomas Thomassen — SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • thomthomT Offline
                                thomthom
                                last edited by

                                I just observed that the UI::Command instance count go down during a session:

                                @unknownuser said:

                                stats
                                150
                                stats
                                144

                                The first one when I started SU.
                                I checked again later after doing some work.

                                So there does appear to be cases when they are released.

                                Thomas Thomassen — SketchUp Monkey & Coding addict
                                List of my plugins and link to the CookieWare fund

                                1 Reply Last reply Reply Quote 0
                                • TIGT Offline
                                  TIG Moderator
                                  last edited by

                                  A breakthrough at last !

                                  If I disable just FredoScale then I can’t get the "gray-out" to occur, no matter how much I try...

                                  Looking at the associated scripts uncovers a lot of complexity and convolution... for example
                                  MYPLUGIN.declare_context_handler_long(scmd, menu, ttip, tc, nil, submenu) { FredoScale.launch code, ’T’ }
                                  uses a Lib6Plugin ’declare_context_handler_long’ that perhaps makes new commands whenever the context is right - i.e. you have selected something that matches ?
                                  It runs tpc = Traductor_Plugin_Command.new
                                  This uses
                                  Traductor_Plugin_Command = Struct.new "Traductor_Plugin_Command", :symb, :proc, :menutext, :icon, :ttip, :valproc, :test_cond, :separator, :submenu, :state, :cmd
                                  etc etc

                                  Perhaps we need to get Fredo directly involved in this as his tool certainly seems to be one of ’the culprits’ ?
                                  It should be possible to recast how this tool works to avoid this problem...

                                  PS: I have tried disabling his other tools with FredoScale active and that has no effect - so it is something about FredoScale and making cmds...

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • thomthomT Offline
                                    thomthom
                                    last edited by

                                    TIG:

                                    
                                    def stats
                                      c=[]
                                      ObjectSpace.each_object(UI;;Command) {|x| c << x }
                                      sprintf("UI;Command objects; %d of 1000 (%.2f%%)", c.length, (c.length / 1000.0) * 100)
                                    end
                                    
                                    

                                    Use this to query how many UI::Command objects exists. If you type stats during your modelling session you can see it change.

                                    @tig said:

                                    Perhaps we need to get Fredo directly involved in this as his tool certainly seems to be one of ’the culprits’ ?
                                    It should be possible to recast how this tool works to avoid this problem...

                                    I sent Fredo a PM last night. He had already been informed by Google then. So he's looking into it.

                                    @tig said:

                                    PS: I have tried disabling his other tools with FredoScale active and that has no effect - so it is something about FredoScale and making cmds...

                                    Do you have ToolsOnSurface? I found that if I click an Edge it would add one UI::Command instance.
                                    Plugins doesn't always show their menus unless the conditions are right. Like Generate Faces that appear only when selecting an Edge. So we won't know for sure which plugins are affected until all the situations are tested.

                                    My current list is:

                                    • Fredoscale - 10 instances per right-click
                                    • ToolsOnSurface - 1 instance per right-click on Edge

                                    v0.2

                                    Thomas Thomassen — SketchUp Monkey & Coding addict
                                    List of my plugins and link to the CookieWare fund

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by

                                      And in case you missed it: this little hack let me get some more info to what creates the UI::Commands: http://forums.sketchucation.com/viewtopic.php?f=15&t=27941&start=15#p243608

                                      Thomas Thomassen — SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • EarthMoverE Offline
                                        EarthMover
                                        last edited by

                                        @tig said:

                                        A breakthrough at last !

                                        If I disable just FredoScale then I can’t get the "gray-out" to occur, no matter how much I try...

                                        Ah-hah! Same here. I disabled Fredoscale & Tools on Surface and am not able to reproduce the same right click issues as earlier. Only problem is, that those tools have become so indispensable that I don't know how to model without them!!!! At least hopefully we are on track to get this HUGE annoyance resolved! It also seems that the "Esc" key is working again. 😍

                                        3D Artist at Clearstory 3D Imaging
                                        Guide Tool at Winning With Sketchup
                                        Content Creator at Skapeup

                                        1 Reply Last reply Reply Quote 0
                                        • thomthomT Offline
                                          thomthom
                                          last edited by

                                          Esc key?

                                          @earthmover said:

                                          Only problem is, that those tools have become so indispensable that I don't know how to model without them!

                                          This is true. But I'm sure there will be a solution for that as well. At least we know more specifically what causes it.
                                          Though I would like to map out better the scenarios how how UI::Command should be used. And have it noted in the API docs.

                                          Thomas Thomassen — SketchUp Monkey & Coding addict
                                          List of my plugins and link to the CookieWare fund

                                          1 Reply Last reply Reply Quote 0
                                          • fredo6F Offline
                                            fredo6
                                            last edited by

                                            @jhauswirth said:

                                            The problem is Ruby scripts are calling-
                                            UI::Command.new
                                            and not attaching the new command to a menu item.

                                            If you want to verify this run-

                                            for i in 0..1000 do
                                            cmd = UI::Command.new("Tester") { UI.messagebox("Hello World") }
                                            end

                                            I can see Ruby scripts creating new commands on each right mouse click.
                                            Every new command creates a unique command ID in SU and there are only 1000
                                            command IDs available. Normally a command is attached to a menu and when
                                            the menu goes away the IDs are recycled, but since these commands are not
                                            attached to a menu, they don't get recycled.
                                            I'm going to try and figure out how to dump the list of commands (they have
                                            menu item text) so that people can see who's causing the problem.

                                            Just to understand what exactly went wrong, can you clarified whether the issue is:
                                            case 1) creating more than 1000 object UI::Command, regardless of any other consideration
                                            case 2) or creating Command objects and not attaching them to menus

                                            In my scripts, the faulty code which I modified was in the style:

                                            
                                            UI.add_context_menu_handler do |menu|
                                               if some tests...
                                                   cmd = UI;;Command.new(menutitle) { do_action}
                                                   cmd.status_bar_text = tooltip
                                                   menu.add_item(cmd)
                                               end	
                                            end 
                                            
                                            

                                            So the issue seems to be the Creation of Command (case 1), not the attachment to menu (case 2). Possibly, since this happens in the contextual menu of the Selection tool, it may be that SU does not release the menu items.

                                            Thanks to advise

                                            Fredo

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 2 / 3
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement