From a6882787b0affd1adbdcdd794998f2a807fd69b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 8 Dec 2016 21:58:31 +0100 Subject: [PATCH] GH-1745 fix crash when using path matching filter on copy operations Copying instances without saves doesn't crash anymore. --- api/logic/InstanceCopyTask.cpp | 20 +++++++++----------- api/logic/InstanceCopyTask.h | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/api/logic/InstanceCopyTask.cpp b/api/logic/InstanceCopyTask.cpp index 3150c383..20c09907 100644 --- a/api/logic/InstanceCopyTask.cpp +++ b/api/logic/InstanceCopyTask.cpp @@ -14,24 +14,22 @@ InstanceCopyTask::InstanceCopyTask(SettingsObjectPtr settings, BaseInstanceProvi m_instName = instName; m_instIcon = instIcon; m_instGroup = instGroup; - m_copySaves = copySaves; + + if(!copySaves) + { + // FIXME: get this from the original instance type... + auto matcherReal = new RegexpMatcher("[.]?minecraft/saves"); + matcherReal->caseSensitive(false); + m_matcher.reset(matcherReal); + } } void InstanceCopyTask::executeTask() { setStatus(tr("Copying instance %1").arg(m_origInstance->name())); - std::unique_ptr matcher; - if(!m_copySaves) - { - // FIXME: get this from the original instance type... - auto matcherReal = new RegexpMatcher("[.]?minecraft/saves"); - matcherReal->caseSensitive(false); - matcher.reset(matcherReal); - } - m_stagingPath = m_target->getStagedInstancePath(); FS::copy folderCopy(m_origInstance->instanceRoot(), m_stagingPath); - folderCopy.followSymlinks(false).blacklist(matcher.get()); + folderCopy.followSymlinks(false).blacklist(m_matcher.get()); m_copyFuture = QtConcurrent::run(QThreadPool::globalInstance(), folderCopy); connect(&m_copyFutureWatcher, &QFutureWatcher::finished, this, &InstanceCopyTask::copyFinished); diff --git a/api/logic/InstanceCopyTask.h b/api/logic/InstanceCopyTask.h index 1ecf8313..28fd3f40 100644 --- a/api/logic/InstanceCopyTask.h +++ b/api/logic/InstanceCopyTask.h @@ -34,9 +34,9 @@ private: /* data */ QString m_instIcon; QString m_instGroup; QString m_stagingPath; - bool m_copySaves = false; QFuture m_copyFuture; QFutureWatcher m_copyFutureWatcher; + std::unique_ptr m_matcher; };