Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 08-08-2020, 09:31 PM   #1
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 1,126
Default API: quitting Reaper while a deferred function is running

Code:
function exit()
  reaper.SNM_SetIntConfigVar('multiprojopt', 1)
end

function run()
  reaper.defer(run)
end

run()
reaper.atexit(exit)
While running this simple code, if I quit reaper I'll get this error message.

Code:
'reaper.SNM_SetIntConfigVar' is unknown
Is this normal?
lexaproductions is offline   Reply With Quote
Old 08-09-2020, 06:53 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Has been reported some time ago as well. This is probably due the fact, that Reaper unloads 3rd-party-extensions before stopping defer-scripts.

I think, it should be the other way round that Reaper stops defer-scripts first, so your error doesn't appear.

But I don't know, what implications would arise from that Reaper-internally...
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-09-2020, 07:07 AM   #3
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 1,126
Default

Ok thanks. So this seems to be working

Code:
function exit()
	local apiExist = reaper.APIExists('SNM_SetIntConfigVar') == true
	if apiExist then
		reaper.SNM_SetIntConfigVar('multiprojopt', 1)
	end
end

function run()
  reaper.defer(run)
end

run()
reaper.atexit(exit)
lexaproductions is offline   Reply With Quote
Old 08-09-2020, 07:43 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Yes, but this also means, that you can't reset config-vars at exit if the function isn't there anymore.
In most cases, this is no problem, as most config-vars aren't persisting unless you set the accompanying ini/projectfile-settings yourself, but there are a few exceptions like the fontsize of the ReaScript-IDE.

So you should check this twice in your scripts for the time being until the issue is resolved in Reaper's extension-unload-behavior.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-09-2020, 08:05 AM   #5
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 1,126
Default

Yeah thanks
I set the config var to the right value upon starting the script anyways so I don’t care for now.

We’ll see in the future.
lexaproductions is offline   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 10:35 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.