Bug 306898 - KConfigGroup: conversion of "0,0,0,0" to QRect failed
Summary: KConfigGroup: conversion of "0,0,0,0" to QRect failed
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: kdecore (show other bugs)
Version: 4.9.1
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-16 18:51 UTC by Laurent Bonnaud
Modified: 2016-03-10 16:56 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Bonnaud 2012-09-16 18:51:42 UTC
When I restore a KDE session, in ~/.xsession-errors, I see many (one per restored window) error messages like this one:

  kwin(2995): ""fsrestore1" - conversion of "0,0,0,0" to QRect failed" 
 [...]

In my ./.kde/share/config/session/kwin_* file, I see lines like this one:

  fsrestore1=0,0,0,0
  [...]

According to Web and bugs.kde.org searches many KDE users (if not all) are affected by this problem. BTW it makes searching for an already reported bug very difficult.


Reproducible: Always

Steps to Reproduce:
1. Record a KDE session with several opened windows
2. Restore this session
3. Look in ~/.xsession-errors
Actual Results:  
Error messages

Expected Results:  
No error message
Comment 1 Thomas Lübking 2012-09-16 19:33:55 UTC
The rect is never assinged, thus remains invalid and written by KConfigGroup as 0,0,0,0 - but KConfigGroup apparently does not read 0,0,0,0 into an (invalid) QRect

-> the bug here is in KConfigGroup, eventually QSettings.

@Martin
Regardless of this i am not sure why we would require this value (instead of just using geom_restore, we'd only have to ensure not to pollute the value when switching from one restorable geometry to another)

@Laurent
> BTW it makes searching for an already reported bug very difficult.
I can make absolutely no sense out of that statement. Mind to elaborate? (What bug and how does this one make searching for that one hard - and are you sure it's not the actually same bug?)

==> passing to kdelibs
Comment 2 Thomas Braxton 2012-09-16 21:39:52 UTC
0,0,0,0 is an invalid QRect since the width and height are 0. So, it looks like a kwin bug, because it is saving a Null QRect.
http://qt-project.org/doc/qt-4.8/qrect.html#isNull
Comment 3 Thomas Lübking 2012-09-16 22:11:17 UTC
The null rect is ok (from KWin's perspective) - means "there's no fullscreen restore geometry (because the window has never been fullscreen)"

The question is: why does KConfigGroup store a null rect but cannot/refuses to restore it, resp. writes an error?
At least i don't see such limitation in the API doc (and does it apply to all invalid non POD, like esp. QString?)

KWin might get fixed implicitly in this regard (see comment #1) but should the validity of (some) non POD actually handled by client code?
Comment 4 Thomas Braxton 2012-09-16 22:27:53 UTC
It does the same thing when it reads most invalid input, it prints an error and returns the defaultValue.
To get rid of the error, don't store invalid data. Instead delete the entry, it will accomplish the same thing without the error.
If I remember right, the errors were put there to point out bugs like this, storing invalid data.
Comment 5 Laurent Bonnaud 2012-09-17 07:48:24 UTC
>> BTW it makes searching for an already reported bug very difficult.
>I can make absolutely no sense out of that statement. Mind to elaborate? (What
>bug and how does this one make searching for that one hard - and are you sure
>it's not the actually same bug?)

Sorry for my lack of clarity.  Here is a second try.

Before I reported this bug I checked if it had already been reported. I saw many matches on the web and on  bugs.kde.org but all of them were unrelated bug and the fsrestore error messages were just noise.
Comment 6 Thomas Lübking 2012-09-17 15:38:48 UTC
a) QString, QStringList and QColor (last writes "invalid"...) are treated gracefully - QRect, QSize, QDateTime are not.

b) if the idea is to prevent storing invalid values, should this not be handled when writing the entries and the invalid state of the variable is known for sure (ie. why should KConfigGroup write what it will refuse to read anyway?)

c) if actually all client code is supposed to do
   if (rect.isValid()) 
        group.writeEntry("Rect", rect);
   else
        group.deleteEntry("Rect");

would it not make sense to do that in KConfigGroup?
At least it should be stressed in the API doc that invalid data can not be restored (for certain types)

Disclaimer:
the code in question is ancient, not written by me, and i don't mind fixing it in either way (preferably removing that variable), but the KConfigGroup behavior in this aspect does not seem consistent *shrug*


@Laurent
ahhh - you googled that string and found all xsession errors ever posted anywhere =)
Be ensured that the error message has absolutely no consequences (the rect is meant to be invalid, kwin will just act as expected)
Comment 7 Thomas Braxton 2012-09-17 17:52:29 UTC
you're probably right about KConfigGroup being inconsistent here, but I'm pretty sure it's been that way since at least 4.0. I think I wanted something stronger here but was overturned. Why would client code want to store invalid data to the config? If the data is invalid it probably shouldn't be in the config. I was just suggesting a way to stop printing the error.
Comment 8 Martin Flöser 2012-09-17 19:56:05 UTC
On Monday 17 September 2012 17:52:29 you wrote:
> https://bugs.kde.org/show_bug.cgi?id=306898
> 
> --- Comment #7 from Thomas Braxton <kde.braxton@gmail.com> ---
> you're probably right about KConfigGroup being inconsistent here, but I'm
> pretty sure it's been that way since at least 4.0.
The KWin code in question is probably much older :-)
> I think I wanted
> something stronger here but was overturned. Why would client code want to
> store invalid data to the config? If the data is invalid it probably
> shouldn't be in the config. I was just suggesting a way to stop printing
> the error.
I think for frameworks 5 it could be useful to try again to get something 
stronger. A client should not need to care about it (at least for the usecase 
of KWin it would be quite some overhead to check whether the values are 
useful)
Comment 9 Thomas Lübking 2012-09-17 20:13:29 UTC
(In reply to comment #7)
> Why would client code want to store invalid data to the config?
a) not looking at it at all (kwin case, but actually any auto-stored data needs to be checked for whether it had a "sane" init then)
b) "abusing" the "invalid" value (internally) but with a different default, ie. 
    QColor a = group.readEntry("Color", Qt::pink); //[1]
    QPen(a.isValid() ? a : b);

(a) would suggest KCG to refuse writing the entry and delete it instead (but needs to be documented)
(b) would suggest to write and read invalid values, but can be considered abuse and bad style.

> I was just suggesting a way to stop printing the error.
Yes, and many thanks for that - but i was already on the big picture =)

[1] I hope there is no Qt::pink and nobody considers it a default irl ;-)
Comment 10 Oswald Buddenhagen 2012-09-17 20:55:17 UTC
i don't think it's any of kcg's business to restrict what values can be stored. it claims to support those data types, not some arbitrary castrates of them.
Comment 11 Laurent Bonnaud 2015-10-02 11:32:26 UTC
This error message is not displayed any longer by kwin 5.x.  Is it OK if I close this bug ?
Comment 12 Thomas Lübking 2015-10-02 13:57:58 UTC
Notice that session management was completely unported before 5.4, so kwin before didn't try to read/write those variable. No idea whether something changed in kconfig.
Comment 13 Laurent Bonnaud 2016-03-10 16:56:18 UTC
This bug was in KDE4 which is now dead wood.