diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2018-10-26 11:41:01 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2018-11-05 13:08:30 +0000 |
commit | a2b41038222b43dd593e57a586a9113395fca678 (patch) | |
tree | 403a7e197d030845f9f7e2c6b0a24aae17ab5eb5 /src | |
parent | 47ae652577a1013736a04e3c9a105b9094fe1ed6 (diff) |
Optimize ExctractArchiveOperation::fileFinished()
This code was spending a lot of time detaching and
copying the file list, due to exporting it via the
setValue() call on each file finished iteration. This
was causing the install process to slow down, and
also made the UI freeze, giving the impression that the
install process had stopped.
Add the file paths to a local list instead, and then
call setValue when file extraction is complete.
Profiling shows that the installer now spends 95% of its
time extracting files on the ExctractArchiveOperation,
thread and 5% on the main thread.
Fixes: QTBUG-51337
Change-Id: Ieb4c44c03cb28eb46928730ca023f7419d72e45b
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/extractarchiveoperation.cpp | 8 | ||||
-rw-r--r-- | src/libs/installer/extractarchiveoperation.h | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/libs/installer/extractarchiveoperation.cpp b/src/libs/installer/extractarchiveoperation.cpp index c41f029e3..128327855 100644 --- a/src/libs/installer/extractarchiveoperation.cpp +++ b/src/libs/installer/extractarchiveoperation.cpp @@ -67,6 +67,8 @@ bool ExtractArchiveOperation::performOperation() connect(runnable, &Runnable::finished, &receiver, &Receiver::runnableFinished, Qt::QueuedConnection); + m_files.clear(); + QEventLoop loop; connect(&receiver, &Receiver::finished, &loop, &QEventLoop::quit); if (QThreadPool::globalInstance()->tryStart(runnable)) { @@ -77,6 +79,8 @@ bool ExtractArchiveOperation::performOperation() receiver.runnableFinished(true, QString()); } + setValue(QLatin1String("files"), m_files); + // TODO: Use backups for rollback, too? Doesn't work for uninstallation though. // delete all backups we can delete right now, remember the rest @@ -121,9 +125,7 @@ bool ExtractArchiveOperation::testOperation() */ void ExtractArchiveOperation::fileFinished(const QString &filename) { - QStringList files = value(QLatin1String("files")).toStringList(); - files.prepend(filename); - setValue(QLatin1String("files"), files); + m_files.prepend(filename); emit outputTextChanged(QDir::toNativeSeparators(filename)); } diff --git a/src/libs/installer/extractarchiveoperation.h b/src/libs/installer/extractarchiveoperation.h index 45c67a9cb..3e75a9bb9 100644 --- a/src/libs/installer/extractarchiveoperation.h +++ b/src/libs/installer/extractarchiveoperation.h @@ -56,6 +56,7 @@ private Q_SLOTS: void fileFinished(const QString &progress); private: + QStringList m_files; class Callback; class Runnable; class Receiver; |