forked from qt-creator/qt-creator
QmlDesigner: Fix crash in FileExtractor when compressed size is 0
Task-number: QDS-9832 Change-Id: Ia096b5770359ea16171cae0634fea340264194e1 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> (cherry picked from commit 86e4d171df3f4afc37a180974c1eb1330b0a1629)
This commit is contained in:
committed by
Tim Jenssen
parent
b15c4e1f75
commit
e442eb9e4c
@@ -51,7 +51,11 @@ FileExtractor::FileExtractor(QObject *parent)
|
||||
|
||||
// We can not get the uncompressed size of the archive yet, that is why we use an
|
||||
// approximation. We assume a 50% compression rate.
|
||||
int progress = std::min(100ll, currentSize * 100 / m_compressedSize * 2);
|
||||
|
||||
int progress = 0;
|
||||
if (m_compressedSize > 0)
|
||||
progress = std::min(100ll, currentSize * 100 / m_compressedSize * 2);
|
||||
|
||||
if (progress >= 0) {
|
||||
m_progress = progress;
|
||||
emit progressChanged();
|
||||
@@ -212,6 +216,8 @@ void FileExtractor::extract()
|
||||
m_timer.start();
|
||||
m_bytesBefore = QStorageInfo(m_targetPath.toFileInfo().dir()).bytesAvailable();
|
||||
m_compressedSize = QFileInfo(m_sourceFile.toString()).size();
|
||||
if (m_compressedSize <= 0)
|
||||
qWarning() << "Compressed size for file '" << m_sourceFile << "' is zero or invalid: " << m_compressedSize;
|
||||
|
||||
QObject::connect(archive, &Utils::Archive::outputReceived, this, [this](const QString &output) {
|
||||
m_detailedText += output;
|
||||
|
Reference in New Issue
Block a user