[Interest] Calling QSettings::value() with an empty key name triggers an assert

Etienne Sandré-Chardonnal etienne.sandre at m4x.org
Thu Oct 3 10:13:09 CEST 2013


Well, I did not want to say "silently" when I said "quietly". I should have
written : "It should fail but in a friendly manner, maybe with a qWarning"

Asserting is not very coherent for many reasons, including:
 - Staying silent in release mode is then a problem.
 - As Q_ASSERTs only work in debug mode they are not a proper solution
here. Q_ASSERTS are there to signal dangerous situations when performance
is critical and should not be degraded in release mode. I'm not sure this
is appropriate here.
 - Why not using an assert when connecting wrong slot and signals, instead
of a warning?
 - While not using an assert in QFile::open when using an empty file name?
 - QSettings::setValue could return a false boolean to warn that the
operation failed.
 - ....


Apart from this, thanks for the explanation about the "." and "Default", I
did not notice it. Maybe this, along with the non-empty requirement, should
be added to setValue() and value() documentation, but you maybe disagree :)

Etienne


2013/10/3 Andre Somers <andre at familiesomers.nl>

>  Op 2-10-2013 17:35, Etienne Sandré-Chardonnal schreef:
>
> So, you're just trying to access the default value in the wrong way. On
> windows, empty key names are also not supported, so the assert is correct.
> The assert is also, IMHO, a better solution than a rather silent fail.
>
> André
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131003/a077ce0f/attachment.html>


More information about the Interest mailing list