Skip to main content

restoreDefault() vs setValue(getDefaultValue())

Comments

7 comments

  • Jeff Gentry

    I'm thinking that the this.q = false is important for figuring this out. Would anyone from the Geneious camp know what the heck q is? I see that setValue() sets it to true and then restoreDefault() sets it back to false. But I can't figure out what setting q is in real life to tweak it and find out.

    0
  • Matthew Cheung

    Hi Jeff,

    That q is hasSetValueBeenCalled.  

    I think there might be a simpler way to achieve what you want.  It sounds like what you want is for the value to never be remembered across runs of the annotation generator.  If that's the case you can use BooleanOption.setRestorePreferenceApplies(false).

    Hope that helps.

    0
  • Jeff Gentry

    Hi - yeah, I did eventually work out that it was `hasSetValueBeenCalled`. It appeared to be private so couldn't try out what I really wanted to try, that is if the following would replicate the same behavior:

    setValue(x)

    setHasSetValueBeenCalled(false)

    As I said, when I call `setValue()` instead of (or after) `restoreAllDefaults()` it worked as expected. I'll try what you suggest to see if that also works. For this use case the users are selecting a region and want the selected sequence to appear in a text box.

    But - my larger question is what changed? The plugin code hadn't been updated in 4 years and the users described this as something that "recently" started to happen. This makes me wonder if something at the Geneious level may have changed?

    0
  • Richard Moir

    My suspicion is that nothing on the code-side changed but instead the behaviour changed once the user typed in a value which in turn got saved to preferences and would be restored each time the plugin is run. Only calling setRestorePreferenceApplies(false) will prevent this from happening.

    In other words, I expect your previous approach would work fine if the user never modified the default value.

    0
  • Jeff Gentry

    I just started working with them so an't say for sure. But that's not how they describe it. The plugin in question, the user selects a region and launches the plugin. The bases get populated into the text field. 

    What they described was that it worked as expected for ~4 years, and then recently stopped working. Instead it started populating the last manually typed value. This is across multiple users.

    0
  • Jeff Gentry

    One thought I had. As I'd been picturing this as being tied to an update in Geneious, if I can get a better sense of timeline on "recently" from the users, assuming it's possible (haven't looked to see) I could try to download an older version of Geneious Prime and compare the two. It could either confirm or deny what's going on here. I'll

    0
  • Jeff Gentry

    Also wanted to confirm that the setRestorePreferenceApplies(false) fix both worked and was cleaner than my original workaround. Thanks!

    0

Please sign in to leave a comment.