diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-11-04 23:35:19 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-11-05 14:09:39 +0100 |
commit | c04b5e0c8c6669b2c4879911e096492df3387911 (patch) | |
tree | cb2b65f46c4f24014428a52c86028ac15607faae /tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp | |
parent | faa854ffeb1e028c401b449f1b18ee3ae92263e0 (diff) |
Tidy up QPixmapCache to prevent potential segfault
Following reports of segfaults in long-running programs leading to
QPixmapCache corruption, clean up some code smells:
* check pointers before dereferencing
We did this in some places, and a default constructed or moved-from key
could have a nullptr KeyData, so check everywhere.
* don't trunctate qsizetype to int
Still plenty of int APIs left, but no need for ints in internal code.
* don't underflow maxCost to -1 if totalCost was 0
* use ranged-for to iterate over list of keys
* guard any public function that might create the cache with the thread-
test
This avoids that the cache ends up living in the wrong thread.
* don't use reinterpret_cast when static_cast is enough (which is always
from void*)
Since the crash is not reproducible so far, and the reports indicate
that it can only be observed when the program has run for a long time,
there is no test case included. However, this removes some code smells
that might be responsible for data corruption.
Pick-to: 6.2
Task-number: QTBUG-97903
Task-number: QTBUG-91445
Task-number: QTCREATORBUG-26473
Change-Id: Ibdd8963d7dd44caab1468ecc6f81ace761719c69
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp')
0 files changed, 0 insertions, 0 deletions