It's not enough to have QSize::isValid, as it needs both width and height
to be 0, so we explicitly check it.
Fixes a warning about writing into an empty image.
Details
Details
- Reviewers
markg - Group Reviewers
Frameworks - Commits
- R302:683bb49d4949: Don't even try to create icons with empty sizes
Diff Detail
Diff Detail
- Repository
- R302 KIconThemes
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
src/kiconengine.cpp | ||
---|---|---|
87 | size.isEmpty()? |
src/kiconengine.cpp | ||
---|---|---|
87 | It took me some minutes to figure this line out. I was "expecting" the isValid call to only return true if with and height are both > 0 Then i figured out that isValid is the wrong function for the task you want to do. if (size.isEmpty()) { // ... } From the Qt docs:
And i tested it for you as well: QSize a(0, 0); QSize b(0, 1); QSize c(1, 1); QSize d(0, -1); qDebug() << a.isEmpty(); // true qDebug() << b.isEmpty(); // true qDebug() << c.isEmpty(); // false qDebug() << d.isEmpty(); // true Exactly how i expect it. |