|
|
|
06-01-2020, 07:02 PM
|
#1
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Philosophical question: Overtaking of Reaper's own PreventUIRefresh?
I'm currently working on some functions for Ultraschall-API, who allow making PreventUIRefresh more stable.
Reason is, that if you have a function, which does
reaper.PreventUIRefresh(-1)
and another function who makes
reaper.PreventUIRefresh(1)
after each other, they cancel each other out.
This can be a problem, if you have in your code reaper.PreventUIRefresh(-1) and a Ultraschall-API function reaper.PreventUIRefresh(1). Both want to prevent UI-refresh but in the end, everything in my Ultraschall-API-function will be visible, as it canceled out the PreventUIRefresh from your script.
Now here's the thing: I can overtake this function to manage it fully independent of what you pass to the function as parameter. That means, I overwrite the Reaper-function with my one, which counts fully on its own and tries to prevent this cancellation for better stability.
And here's my question from an ethical and philosophical point: assuming I can pull it off: shall I do it or do you prefer Reaper's own function to be untouched?
|
|
|
06-01-2020, 07:11 PM
|
#2
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 15,823
|
This is why PreventUIRefresh() keeps an internal counter. You should always call PreventUIRefresh(1) to initiate and PreventUIRefresh(-1) to end, not the other way around. That will ensure that refresh remains in the prevent state until everyone who called to initiate it has called to end it.
|
|
|
06-01-2020, 07:16 PM
|
#3
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Ah, thanks.
|
|
|
06-01-2020, 07:23 PM
|
#4
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
@schwa
Would adding a function like:
reaper.GetCurrentUIRefreshCounter()
possible? So I can check in my functions if I need to use PreventUIRefresh in the first place.
That way, I can prevent possible cancellations, when people first subtract and then add by accident. I just like to make my stuff as rock solid as possible without interfering in the code of scripters.
|
|
|
06-01-2020, 07:27 PM
|
#5
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 15,823
|
If some caller initiates the call with -1, that should be considered a bug. It's like a reference count, designed to be used by multiple callers who don't need to know about the existence of the others.
|
|
|
06-01-2020, 07:32 PM
|
#6
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Quote:
Originally Posted by schwa
If some caller initiates the call with -1, that should be considered a bug. It's like a reference count, designed to be used by multiple callers who don't need to know about the existence of the others.
|
Sure but I cannot check this happening at all currently so I can not give any feedback to the user of my functions for them to correct it. I can only take care of my own bugs.
Unless I overtake PreventUIRefresh and count an internal counter as well, and if it ever tries to go into negative areas, I throw a Lua-error.
BTW: does PreventUIRefresh check, whether someone tries to go into negative areas currently and prevents that? If not, maybe an error-message or at least no ui-refresh-prevention possible would be good.
So people can not use it wrong, as the first call to PreventUIRefresh(-1) wouldn't prevent UIRefresh at all. That could make coders think about, how to do it correctly rather than continuing the wrong way.
Could break some old scripts though but well...
|
|
|
06-01-2020, 07:38 PM
|
#7
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 15,823
|
Our general approach the API is to only lightly check inputs and let bad extensions blow up REAPER. Unless you have a known case of somebody calling this function backwards (the documentation does say "add then remove"), I wouldn't bother changing the internals.
|
|
|
06-01-2020, 07:53 PM
|
#8
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Ok. But nevertheless, a way of getting the current counter would still be helpful for these edgecases. So I can deal with it properly in my functions, even if it's only a problem in a handful of cases.
I spend a lot of time to prevent possible misuses of my functions and I always feel a little brr brr brr, for not having a way to deal with UIRefresh that well.
If I could get the counter, I could deal with it properly.
In the end, it's all about not bothering unsuspecting endusers with unexpected flickerings of their UI just because of edge-cases.
|
|
|
06-01-2020, 07:58 PM
|
#9
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Oh, and are the counters reset after a script finishes? Or can a forgotten PreventUIRefresh(-1) still prevent UI refresh after script is finished?
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:03 PM.
|