forked from qt-creator/qt-creator
StringTable: Fix isQStringInUse()
With the current implementation it always returns true, even when there is only one existing copy of a string inside m_strings set, without any reference. This is due to creating a copy of the QArrayDataPointer: 1 QArrayData::ref / qarraydata.h 2 QArrayDataPointer<char16_t>::ref / qarraydatapointer.h 438 3 QArrayDataPointer<char16_t>::QArrayDataPointer / qarraydatapointer.h 40 4 isQStringInUse So, the ref_ is always at least 2. Avoid creating a copy by taking a reference instead. Observed misbehavior: After switching session nothing is erased from the m_strings, it cumulates indefinitely instead. Task-number: QTCREATORBUG-18800 Change-Id: I17981d44f88307e736ec03380baa39a03f0719bf Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
@@ -103,7 +103,7 @@ static int bytesSaved = 0;
|
||||
|
||||
static inline bool isQStringInUse(const QString &string)
|
||||
{
|
||||
QStringPrivate data_ptr = const_cast<QString&>(string).data_ptr();
|
||||
QStringPrivate &data_ptr = const_cast<QString&>(string).data_ptr();
|
||||
if (DebugStringTable) {
|
||||
const int ref = data_ptr->d_ptr()->ref_;
|
||||
bytesSaved += (ref - 1) * string.size();
|
||||
|
Reference in New Issue
Block a user