ZBrushCentral

Bug: Selecting SubTools via loop inside IFreeze breaks hotkeys & tooltips

Hello,

I’ve been doing a lot of ZScripting recently and for the most part it’s working fine and as I expect. However, I’ve hit a bug which seems very specific and 100% reproducible.


  • Create an “IFreeze” block containing a section of code where you loop through all SubTools, selecting each one in turn
  • At the end of the loop you will not be able to use some hotkeys for common actions (eg. Ctrl+Shift+Click to toggle polygroup visibility)
  • Additionally, Tooltips will no longer display at all
  • The only way to resolve this is to restart ZBrush :frowning:
  • Removing the IFreeze block (so that the display updates every time a SubTool is selected by the script) means that this issue will not occur - hotkeys and tooltips will be fine after script execution
  • Interestingly, this only occurs if you loop through the SubTools. If you just select a single SubTool via script inside the IFreeze block, then nothing breaks.

I’ve got an example here; it’s based on a script that loops through all SubTools and sets their SDiv level to a value specified by a slider. In this example I’ve just removed all specific stuff - the bug still occurs even if all you do is loop through selecting each SubTool and never actually do anything with the SubTool, as long as IFreeze is on.


// Set all SubTools to a specified SDiv level.
[RoutineDef, sd_SetSDiv,
    [IShowActions, 0]
    [IFreeze, // Comment this out to make the script work without breaking hotkeys/tooltips
        [If, [IExists, "Tool:SubTool:SelectDown"], // Just make sure that the SubTool palette exists first...
            [VarSet, numSubTools, [StrExtract, [IGetTitle, "Preferences:Misc:SubTools Count"], 10, 256]]
            
            // Get to the top subtool
            [ISet, "Tool:Sub Tool:SubTool ScrollBar", 0, ( #numSubTools - 1 )]
            [IPress, "Tool:Sub Tool 0"]
            
            [VarSet, stIndex, [Val, #numSubTools]]
            [Loop, #numSubTools,
                [VarDec, stIndex]
                
                [ISet, "Tool:Sub Tool:SubTool ScrollBar", 0, #stIndex]
                [If, [IsEnabled, "Tool:Sub Tool 0"], [IPress, "Tool:Sub Tool 0"]]
            ]
        ]
    ] // Comment this out if you've commented out IFreeze
    [IShowActions, -1]
]

For the time being, I’ve just removed the IFreeze - the script works fine and nothing breaks. However, I feel like it should work (and be faster?), so I’d like to know if anyone knows what’s going on here. It’d be nice if IFreeze didn’t break stuff at the end…

Help me, marcus_civis, you’re my only hope! :wink:
(Or anyone else who knows a way around this would be nice).

Cheers,
-MoP

I think this may have been mentioned before. Anyway, if you put [IUpdate] at the start of (and inside) the loop all should be well.

HTH,

Thanks for the fast response, marcus, that’s interesting. I did try adding some IUpdate calls inside the loop already and it didn’t work, but maybe I didn’t add one at the start like you mention… I’ll try this now.

However… doesn’t this defeat the purpose of using IFreeze in the first place? :o

No, because the default behaviour of IUpdate is not to redraw the UI.

Sorry, yes, you’re right. That works now, the view doesn’t refresh and the hotkeys/tooltips still work after running the script.

I found your original thread mentioning this issue actually (although it seemed to have slightly different issues arising from it). Foolishly I didn’t actually use this forum’s own search function, I relied on Google instead which didn’t throw up that link. I know where I’ll be looking first in future :slight_smile:

It’s been 7 years since you first discovered this bug… I’m guessing Pixologic isn’t planning to fix this behaviour? It’s a very odd hoop to have to jump through in order to make something function as intended, and not documented at all. :frowning:

Yes, I guess it’s not high priority. But I’ll add a note to the documentation.