[Development] QSettings refactor updates

Tomaz Canabrava tcanabrava at kde.org
Sat Oct 11 15:22:07 CEST 2014


Em 11/10/2014 09:20, "Rafael Roquetto" <rafael.roquetto at kdab.com> escreveu:
>
> On Fri, Oct 10, 2014 at 09:26:11PM -0300, Tomaz Canabrava wrote:
> > On Fri, Oct 10, 2014 at 6:35 AM, Milian Wolff <milian.wolff at kdab.com>
wrote:
> >
> <snip>
> >
> > It's too error prone regarding typos.
>
> This is easily solved by using constants instead of string literals.
>
>  const QLatin1String SettingsGroup("blah");
>  const QLatin1String WidthKey("width");

It's not, as a string is not group aware.

>  KConfig c;
>  KConfigGroup g = c.group(SettingsGroup);
>  g.setValue(WidthKey, 10);

KConfigGroup other = c.group(OtherSettings)
Other.setValue(WrongKeyForThisGroup);

>  //  otherfile
>  Kconfig c;
>  KConfigGroup g = c.group(SettingsGroup);
>  g.value(WidthKey);
>
>
> How do you intend to fix string literal typos? IMHO compile-time checks
are
> better than run-time checks in these cases.

They are much better, agreed, but I plan to add run time checks first since
its easier to do, and in the future add a new binary to check for settings
Inconsiatencies based on a schema.

> Cheers,
> Rafael
>
> --
> Rafael Roquetto | rafael.roquetto at kdab.com | Software Engineer
> Klarälvdalens Datakonsult AB, a KDAB Group company
> Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
> KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20141011/158bc1f6/attachment.html>


More information about the Development mailing list