-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
@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. :) |
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 |
I'm basically just copying the logic of the other 'default on' buttons. SetupDialog.cpp and I aren't really on speaking terms... |
Merge?
Yes, something like that. In any case I've never had an easy time when I've touched that file. |
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. |
I didn't get this.
Sorry. I don't have much time now. |
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 |
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. Here's a hacked proposal... (better proposal below) Note, this has some implications... namely, it potentially enables 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 ------^ |
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 |
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. |
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. |
Superseded by #3551. |
Provide support for fallback config values Makes autosave and some other values checked by default. Supersedes #3541
Provide support for fallback config values Makes autosave and some other values checked by default. Supersedes LMMS#3541
Provide support for fallback config values Makes autosave and some other values checked by default. Supersedes LMMS#3541
Autosave regression #181 (comment)
Introduced here: 901fea5