Very strange expression in pluginmanager.cpp

Found the next line in pluginmanager.cpp (line 651 in master):

if(settings.value(factory->identifier(), true).toBool())

where factory->identifier() is an arbitrary QString.


Regards,
Konstantin

Found the next line in pluginmanager.cpp (line 651 in master):
if(settings.value(factory->identifier(), true).toBool())

I’m catching up on back messages…

This isn’t that strange, it’s just hard to read code and needs a comment. We store a boolean value keyed by the plugin identifier – this indicates whether the plugin is enabled or not.

Something like:

“Axes Engine” -> true
"Surface Engine" -> false

Does this make more sense now? settings.value(“string”, defaultValue) returns the value of the settings at key “string”, and a default value of true if it doesn’t exist. We then make sure the QVariant returned from settings.value is converted to a boolean.

Cheers,
-Geoff

22.11.2010, 01:07, “Geoffrey Hutchison” geoff.hutchison@gmail.com:

Found the next line in pluginmanager.cpp (line 651 in master):
if(settings.value(factory->identifier(), true).toBool())

I’m catching up on back messages…

This isn’t that strange, it’s just hard to read code and needs a comment. We store a boolean value keyed by the plugin identifier – this indicates whether the plugin is enabled or not.

Something like:

“Axes Engine” -> true
"Surface Engine" -> false

Does this make more sense now? settings.value(“string”, defaultValue) returns the value of the settings at key “string”, and a default value of true if it doesn’t exist. We then make sure the QVariant returned from settings.value is converted to a boolean.

This is strange because we could simply store boolean in QVariant.
Is there any reason against it?


Regards,
Konstantin

22.11.2010, 11:39, “Konstantin Tokarev” annulen@yandex.ru:

22.11.2010, 01:07, “Geoffrey Hutchison” geoff.hutchison@gmail.com;:

Found the next line in pluginmanager.cpp (line 651 in master):
if(settings.value(factory->identifier(), true).toBool())
I’m catching up on back messages…

This isn’t that strange, it’s just hard to read code and needs a comment. We store a boolean value keyed by the plugin identifier – this indicates whether the plugin is enabled or not.

Something like:

“Axes Engine” -> true
"Surface Engine" -> false

Does this make more sense now? settings.value(“string”, defaultValue) returns the value of the settings at key “string”, and a default value of true if it doesn’t exist. We then make sure the QVariant returned from settings.value is converted to a boolean.

This is strange because we could simply store boolean in QVariant.
Is there any reason against it?

or !factory->identifier().isEmpty()
(but I don’t think that settings should be thrown away for disabled plugin)


Regards,
Konstantin

Sorry, I probably need more coffee :slight_smile:


Regards,
Konstantin