Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 06-15-2017, 01:28 PM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,010
Default Reascript: Restore original behavior of PreventUIRefresh to make actions faster

Once upon a time, it was possible to use the function PreventUIRefresh to make execution of custom actions fast and fluid by preventing UI updates in-between the component actions.

The original PreventUIRefresh could probably also have been used to make deferred MIDI editing scripts run faster, by preventing the arrange window from updating while the deferred script is running. (NB: REAPER's native MIDI editing mouse modifier actions do not update the arrange window while the action is running, either.)

Unfortunately, in some version after 5.00, the behavior of PreventUIRefresh changed. In the present versions, REAPER automatically resets the UI refresh state after each action, and after each defer cycle:
Quote:
Originally Posted by X-Raym View Post
These scripts doesn't work because a post 5.0 REAPER updates put a prevention system for "orphelin" prevent UI refresh not resolve in a scripts (for eg, if you script broke before the PreventUIRefresh(-1) call, the interface will be buggy, untill you call PreventUIRefresh(-1) yourself. The fix aims to prevent that.
For both of the applications mentioned above, it would be useful if the original behavior of PreventUIRefresh could be restored.

Admittedly, careless scripts that use PreventUIRefresh improperly would then be able to freeze REAPER, but many other API functions and/or buggy programming can also cause crashes or freezing.

Last edited by juliansader; 06-18-2017 at 11:44 AM.
juliansader is online now   Reply With Quote
Old 06-15-2017, 02:14 PM   #2
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,010
Default

The function PreventUIRefresh would be less tricky to use if its parameter was boolean instead of an integer.

In current versions of the API, the description of the function reads:**
Quote:
Lua: reaper.PreventUIRefresh(integer prevent_count)

adds prevent_count to the UI refresh prevention state; always add then remove the same amount, or major disfunction will occur
By using a boolean, the refresh state can be restored by a simple reaper.PreventUIRefresh(false), instead of having to keep track of a prevent_count that may be modified by other scripts and actions.


** This description is not actually correct. As mentioned in the previous post, current versions of REAPER automatically restores the refresh state, so no major dysfunction will occur.
juliansader is online now   Reply With Quote
Old 06-18-2017, 11:47 AM   #3
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,010
Default

Perhaps, instead of restoring the original behavior of PreventUIRefresh, a new function that uses a simple boolean parameter (and that remains in effect across defer cycles and custom actions) could be added to the API:
Code:
Lua: PreventUIRefresh2(ReaProject* proj, boolean prevent)
juliansader is online now   Reply With Quote
Old 06-18-2017, 01:44 PM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 3,964
Default

Off topic but related to the same issue :

Custom Action: Prevent UI Refresh Checkbox - Cockos Incorporated Forums

@juliansader
Actually I'm fine with the current behavior, before that, debugging Lua script was a pain cause you were assured that you would got UI refresh errors if the scripts didn't end normally (which it didn't cause it is dev stage, and there is always bugs ^^)

I think another trick have to be found to the make deferred MIDI editing scripts run faster issue, I'm not sure that prevent UI refresh will do the trick. But sure, any trick to optimize/make this MIDI faster has to be considered.
X-Raym is offline   Reply With Quote
Old 06-18-2017, 01:59 PM   #5
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 1,551
Default

Personally I get the usefulness of having the integer count the number of times it has been called and then removed - as this would help nested functions and recursive function calls where you may have disable updating called at the top of a function and then enable at the bottom.

But having a simple true false means the first time false is called - screen updating gets enabled when you may not want it to be (and you'd need to add extra code to prevent this).

However - I agree that maybe it should persist across a deferred loop, and possibly get round the problem X-Raym pointed out that if an error occurs in the script (unhandled - not that I've had any success handling errors in Reascript :| ) - then reaper could automatically re-enable updating in the error reporting code.
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine
Donate via Paypal
lb0 is offline   Reply With Quote
Old 06-18-2017, 02:02 PM   #6
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,010
Default

Quote:
Originally Posted by X-Raym View Post
I think another trick have to be found to the make deferred MIDI editing scripts run faster issue, I'm not sure that prevent UI refresh will do the trick. But sure, any trick to optimize/make this MIDI faster has to be considered.
I have submitted another FR for a new API function that may also do the trick: Reascript: new function MIDIEditor_Update for faster MIDI scripts.
juliansader is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:07 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.