Review Request 122232: KConfig: fix using KSharedConfig in global object destructor.

David Faure faure at kde.org
Mon Jan 26 08:10:50 UTC 2015



> On Jan. 24, 2015, 5:12 p.m., Matthew Dawson wrote:
> > src/core/kconfig.cpp, line 542
> > <https://git.reviewboard.kde.org/r/122232/diff/1/?file=344445#file344445line542>
> >
> >     Reading the Qt documentation, I think its possible that appArgs[0] isn't the application name on Windows, and thus appArgs may stay empty.
> >     
> >     Maybe add another conditional checking its empty in this if statement, and if it still is add some random value?
> 
> David Faure wrote:
>     It's possible that appArgs[0] is not the app name, but I'm pretty sure the QStringList we get from QCoreApplication is never empty.
> 
> Matthew Dawson wrote:
>     I don't have a Windows machine to test this theory on.  Could you forward this commit to the KDE Windows developers, so they can double check and fix as necessary?  Since this solves the bug on *nix platforms, and should mostly solve it on Windows, I don't think blocking this version over this issue is worthwhile then.

I read the qcoreapplication.cpp code, and it ensures that the number of arguments is respected, it's just that it grabs them in unicode instead of 8-bit.

So arguments() is never empty.... except when the warning "no QCoreApplication yet" is printed, which this commit fixes.
(and the empty list doesn't lead to e.g. a crash, just to querying again next time, so that's fine)

Calling initConfig() before the QApp ctor still leads to that warning, though, obviously. But I think that's fine, one should create a QApp before anything else (and avoid global static constructors running before main, anyway).


- David


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122232/#review74671
-----------------------------------------------------------


On Jan. 23, 2015, 10:39 p.m., David Faure wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/122232/
> -----------------------------------------------------------
> 
> (Updated Jan. 23, 2015, 10:39 p.m.)
> 
> 
> Review request for KDE Frameworks, Albert Astals Cid and Matthew Dawson.
> 
> 
> Repository: kconfig
> 
> 
> Description
> -------
> 
> kconfig_in_global_object.cpp comes from kdelibs4support
> (after porting to Q_GLOBAL_STATIC)
> 
> ksharedconfig_in_global_object.cpp is new (but works with kdelibs4)
> and reproduces Albert's KgDifficulty testcase.
> 
> 
> Diffs
> -----
> 
>   autotests/CMakeLists.txt b91f754b705fc87bb8b729bea72fbb5f7d427ace 
>   autotests/kconfig_in_global_object.cpp PRE-CREATION 
>   autotests/ksharedconfig_in_global_object.cpp PRE-CREATION 
>   src/core/kconfig.cpp 782e9714521234a3e3d8f3a788967e5c9a40f38a 
> 
> Diff: https://git.reviewboard.kde.org/r/122232/diff/
> 
> 
> Testing
> -------
> 
> Both tests pass and the QCoreApplication::arguments warning (because called after qApp is destroyed) is gone.
> 
> 
> Thanks,
> 
> David Faure
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20150126/903df174/attachment.html>


More information about the Kde-frameworks-devel mailing list