Utils: Don't call mutable expressions inside QTC_ASSERT

In order to conform to the theory: "Removing all
QTC_ASSERTs and QTC_CHECKs should not change anything".

Change-Id: I6f5c4486afb422301562d79c662fdde026e4d788
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2022-12-09 00:06:39 +01:00
parent a6b17d127a
commit 36be7b8375
3 changed files with 11 additions and 6 deletions

View File

@@ -560,7 +560,8 @@ bool DesktopDeviceFileAccess::writeFileContents(
qint64 offset) const
{
QFile file(filePath.path());
QTC_ASSERT(file.open(QFile::WriteOnly | QFile::Truncate), return false);
const bool isOpened = file.open(QFile::WriteOnly | QFile::Truncate);
QTC_ASSERT(isOpened, return false);
if (offset != 0)
file.seek(offset);
qint64 res = file.write(data);

View File

@@ -48,7 +48,8 @@ bool FSEngineImpl::open(QIODevice::OpenMode openMode)
ensureStorage();
QTC_ASSERT(m_tempStorage->open(), return false);
const bool isOpened = m_tempStorage->open();
QTC_ASSERT(isOpened, return false);
bool read = openMode & QIODevice::ReadOnly;
bool write = openMode & QIODevice::WriteOnly;
@@ -76,7 +77,8 @@ bool FSEngineImpl::open(QIODevice::OpenMode openMode)
bool FSEngineImpl::close()
{
QTC_ASSERT(flush(), return false);
const bool isFlushed = flush();
QTC_ASSERT(isFlushed, return false);
if (m_tempStorage)
m_tempStorage->close();
return true;

View File

@@ -117,7 +117,8 @@ private:
void handleFinished()
{
// In case the process is still running - wait until it has finished
QTC_ASSERT(emitFinished(), QTimer::singleShot(m_reaperSetup.m_timeoutMs,
const bool isFinished = emitFinished();
QTC_ASSERT(isFinished, QTimer::singleShot(m_reaperSetup.m_timeoutMs,
this, &Reaper::handleFinished));
}
@@ -187,7 +188,8 @@ private:
Reaper *reaper = new Reaper(reaperSetup);
connect(reaper, &Reaper::finished, this, [this, reaper, process = reaperSetup.m_process] {
QMutexLocker locker(&m_mutex);
QTC_CHECK(m_reaperList.removeOne(reaper));
const bool isRemoved = m_reaperList.removeOne(reaper);
QTC_CHECK(isRemoved);
delete reaper;
delete process;
if (m_reaperList.isEmpty())