Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on_script_unload() and property saving bug #205

Open
regorxxx opened this issue Feb 19, 2023 · 3 comments
Open

on_script_unload() and property saving bug #205

regorxxx opened this issue Feb 19, 2023 · 3 comments

Comments

@regorxxx
Copy link

on_script_unload() when foobar is closed (without errors) is behaving badly.

I have a code to save a property on script unload and it works fine on panel reload, but it doesn't work when closing foobar.

  1. If you add this code to a new panel and immediately close foobar, after restarting the properties panel is empty. (*)
const p = ['name', 'value'];

function on_script_unload(){
	window.SetProperty(p[0],p[1]);
}
  1. On the other hand, if you simply add the code and reload the panel. It's added fine.

(*) Note you can not do this after panel reload, since cleaning the properties reloads the script again and adds the properties (being equivalent to 2).

regorxxx added a commit to regorxxx/Search-by-Distance-SMP that referenced this issue Feb 19, 2023
…which made properties not being saved when closing foobar. That made the initial popups on first installation to keep firing on every restart.
@marc2k3
Copy link
Contributor

marc2k3 commented Feb 19, 2023

JSP3 has this issue too but there isn't anything that can be done (other than clarifying in the docs).

Code inside the callback definitely runs because I tested writing an external text file which works.

The issue here is that that fb2k itself is writing the panel configuration to theme.fth (DUI) or foo_ui_columns.dll.cfg (CUI) before we get notified that it is shutting down. Any subsequent changes made by window.SetProperty are lost in the ether.

Component authors control what is written to layout files but not when.

@regorxxx
Copy link
Author

regorxxx commented Feb 19, 2023

Yep, found the same logging to a file. The properties are properly written to the panel within the callback (GetProperty gets the updated value) but not saved to the config file.

A warning should be added then to be cautious about what code is run there.

@marc2k3
Copy link
Contributor

marc2k3 commented Feb 19, 2023

I've added a note to my own docs...

https://jscript-panel.github.io/docs/callbacks/#on_script_unload

regorxxx added a commit to regorxxx/Playlist-Tools-SMP that referenced this issue Mar 13, 2023
… when using 'Run when closing foobar?' option due to a limit on how [foobar2000/SMP work](TheQwertiest/foo_spider_monkey_panel#205). A workaround has been implemented, considering a button should always be on an specific state at init if these options were used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants