AAVSO / VStar

VStar is a visualisation and analysis tool for variable star data brought to you by AAVSO
https://www.aavso.org/vstar
GNU Affero General Public License v3.0
10 stars 3 forks source link

Some preferences are not read/saved in WebStart mode #280

Closed mpyat2 closed 2 years ago

mpyat2 commented 2 years ago

In WebStart mode, some preferences (i.e. series size/color, locale) are not read nor saved.

mpyat2 commented 2 years ago

@dbenn , if I understand correctly, we decided to get rid of WebStart al all.

This means that this issue probably could be closed.

By the way, I've found a source of the problem (and even made a fix which is useless now, I guess): While loading, some plug-ins may access LocaleProps and StarGroups classes. Those classes have static 'Preferences prefs' fields. The prefs fields are initialized by a 'static' piece of code whet the class is referenced first. Since the class is referenced first from a plug-in, 'prefs' is not initialized because of a lack of permissions. To overcome this, we can make an empty public static method, for example: public static void initClass() {}

and call this method before loading the plug-ins in VStar.java:

        // Classes SeriesType and LocaleProps have static prefs members of Preferences type;
        // those members cannot be created from within plug-ins in WebStart mode due to security restrictions.
        // As far as 'prefs' in both classes are created with a 'static' block of code, any reference to the class
        // initializes 'prefs'. This is ensured by a call of the empty initClass() method.
        // After initialization, 'prefs' can be accessed from within plug-ins.
        SeriesType.initClass();     
        LocaleProps.initClass();

        // If there's no command-line option that says we shouldn't load
        // plug-ins and the plug-in manager says it's okay to load them, then go
        // ahead.
        if (loadPlugins && PluginManager.shouldLoadPlugins()) {
            // Load plug-ins, if any exist and plug-in loading is enabled.
            PluginLoader.loadPlugins();
        }

This fixes the problem.

dbenn commented 2 years ago

Hi @mpyat2

This seems like a Good Idea.

Feel free to commit and I'll merge when I wake up in several hours. :)

David

dbenn commented 2 years ago

As you say, if we are moving away from WebStart, a fix for this is less important, but people will still use WebStart for some time, so fixing this is a Good Thing in the short term.

dbenn commented 2 years ago

Hi @mpyat2. I have not yet tested this via WebStart (which we are planning to move away from now) but I suspect you have. Happy to close this issue when you are.

mpyat2 commented 2 years ago

Yes, please close it, @dbenn !