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

Fix regression where autosave function is off by default #3541

Closed
wants to merge 1 commit into from

Conversation

zonkmachine
Copy link
Member

Autosave regression #181 (comment)

Introduced here: 901fea5

@zonkmachine zonkmachine requested a review from Umcaruje May 8, 2017 05:11
@zonkmachine zonkmachine changed the title Fix regression where autosave function is off by defautl Fix regression where autosave function is off by default May 8, 2017
@tresf
Copy link
Member

tresf commented May 8, 2017

@zonkmachine thanks. Although this fixes the problem in the UI, can you help explain what's happening in the config? Is this value being stored incorrectly as code looks backwards now. :)

@tresf
Copy link
Member

tresf commented May 8, 2017

Ok... I think I see what happened... @jasp00 complained about double-negatives in our variable names, but we don't currently seem to have a way to default an unconfigured property to enabled, right?

@zonkmachine
Copy link
Member Author

I'm basically just copying the logic of the other 'default on' buttons. SetupDialog.cpp and I aren't really on speaking terms...

@zonkmachine
Copy link
Member Author

Merge?

but we don't currently seem to have a way to default an unconfigured property to enabled, right?

Yes, something like that. In any case I've never had an easy time when I've touched that file.

@tresf
Copy link
Member

tresf commented May 9, 2017

Merge?

No unfortunately now the code is backwards, so the patch is masking the problem.

@jasp00's advice was pragmatic but impractical. We either revert the variable naming to what the project uses and keep this type of patch, or spend the time necessary to have default-on in our config file.

@zonkmachine
Copy link
Member Author

We either revert the variable naming to what the project uses and keep this type of patch,

I didn't get this.

or spend the time necessary to have default-on in our config file.

Sorry. I don't have much time now.

@tresf
Copy link
Member

tresf commented May 10, 2017

I'm not sure how else to phrase this properly....

m_enableAutoSave( !ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() ),

This essentially says

m_enableAutoSave = !enableautosave;

These are the same conceptual concerns @jasp00 raised in #3088.

There's likely a better way to handle this all in our ConfigManager class to actually fix the underlying problem of default int value is zero. Alternately, we can go back to the old disableautosave verbiage and just let it be zero blank -- resolving to zero -- naturally, but the logic proposed in this PR is incorrect.

@tresf
Copy link
Member

tresf commented May 10, 2017

Ok... I'd appreciate a second set of eyes on this, but if what I'm observing is true, all of our booleans can never be true by default, which punishes anyone that wants a "default on" value (e.g. enablefoo) without a "default off" sounding name (e.g. disablefoo)

Here's a hacked proposal... (better proposal below)

Note, this has some implications... namely, it potentially enables animateafp, displaydbfs and enableautosave by default, but it uses a parses a String to determine what we "meant". It's the wrong way, but illustrates the problem.

const QString & ConfigManager::value( const QString & cls,
					const QString & attribute ) const
{
	if( m_settings.contains( cls ) )
	{
		for( stringPairVector::const_iterator it =
						m_settings[cls].begin();
					it != m_settings[cls].end(); ++it )
		{
			if( ( *it ).first == attribute )
			{
				return ( *it ).second ;
			}
		}
	}
	static QString empty
+	// Default enable flags to true
+	static QString on("1");
-	return empty;
+	return attribute.startsWith("enable") ||
+		attribute.startsWith("animate")  ||
+		attribute.startsWith("display") ? on : empty;
}

The better proposal... add new function that accepts a default value when one can't be found... (pseudocode, untested).

Worth noting, this is the technique that every config parser I've ever seen handles default values.

const QString & ConfigManager::value( const QString & cls, const QString & attribute, const QString & defaultVal ) const
{
	QString val = value(cls, attribute);
        return val.isEmpty() ? defaultVal : val;
}

Usage:

m_enableAutoSave( ConfigManager::inst()->value( "ui", "enableautosave", "1" ).toInt() ),
//                                                  DEFAULT VALUE  ------^

@zonkmachine
Copy link
Member Author

Alternately, we can go back to the old disableautosave verbiage and just let it be zero blank -- resolving to zero -- naturally, but the logic proposed in this PR is incorrect.

So, just reverting 901fea5 ?
I suggest you start a separate issue with the above proposed code. I'm not going to have time to implement anything like that here and now.

@tresf
Copy link
Member

tresf commented May 10, 2017

So, just reverting 901fea5 ?

That was my original thought, but please read the bottom of the post, I provided a better fix that's only a few lines and allows us to keep the enabled flag.

@zonkmachine
Copy link
Member Author

That was my original thought, but please read the bottom of the post, I provided a better fix that's only a few lines and allows us to keep the enabled flag.

Still not within my time limit. What I can do is revert 901fea5. I won't have time to look any deeper into things right now and for a possible long time coming.

@tresf
Copy link
Member

tresf commented May 10, 2017

Still not within my time limit.

Someone else will have to tackle it then. This PR is as good as a bug report since it contains the valid info. We'll either supercede this will a new PR or use this PR directly for the code.

@tresf tresf added this to the 1.2.0 milestone May 10, 2017
tresf added a commit to tresf/lmms that referenced this pull request May 11, 2017
@tresf
Copy link
Member

tresf commented May 11, 2017

Superseded by #3551.

@tresf tresf closed this May 11, 2017
tresf added a commit that referenced this pull request May 14, 2017
Provide support for fallback config values

Makes autosave and some other values checked by default.  Supersedes #3541
@zonkmachine zonkmachine deleted the autosaveon branch May 14, 2017 08:17
PhysSong pushed a commit to PhysSong/lmms that referenced this pull request Jul 8, 2017
Provide support for fallback config values

Makes autosave and some other values checked by default.  Supersedes LMMS#3541
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
Provide support for fallback config values

Makes autosave and some other values checked by default.  Supersedes LMMS#3541
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

Successfully merging this pull request may close these issues.

2 participants