diff --git a/launcher/BaseInstance.cpp b/launcher/BaseInstance.cpp index 5ffbb809b..92d41521b 100644 --- a/launcher/BaseInstance.cpp +++ b/launcher/BaseInstance.cpp @@ -388,10 +388,9 @@ void BaseInstance::setName(QString val) emit propertiesChanged(this); } -bool BaseInstance::syncInstanceDirName() const +bool BaseInstance::syncInstanceDirName(const QString& newRoot) const { auto oldRoot = instanceRoot(); - auto newRoot = FS::PathCombine(QFileInfo(oldRoot).dir().absolutePath(), name()); if (oldRoot == newRoot) return true; if (!QFile::rename(oldRoot, newRoot)) diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h index b19f1fd27..2a2b4dc4a 100644 --- a/launcher/BaseInstance.h +++ b/launcher/BaseInstance.h @@ -127,7 +127,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_thisinstanceRoot(); auto oldName = QFileInfo(oldRoot).baseName(); - auto newRoot = FS::PathCombine(QFileInfo(oldRoot).dir().absolutePath(), instance->name()); + auto newName = FS::DirNameFromString(instance->name(), QFileInfo(oldRoot).dir().absolutePath()); + auto newRoot = FS::PathCombine(QFileInfo(oldRoot).dir().absolutePath(), newName); if (oldRoot == newRoot) return false; @@ -69,7 +70,7 @@ bool askToUpdateInstanceDirName(InstancePtr instance, QWidget* parent) if (renamingMode == "AskEverytime") { QMessageBox messageBox(parent); messageBox.setText(QObject::tr("Would you also like to rename the instance folder?")); - messageBox.setInformativeText(QObject::tr("Renaming \'%1\' -> \'%2\'").arg(oldName, instance->name())); + messageBox.setInformativeText(QObject::tr("Renaming \'%1\' -> \'%2\'").arg(oldName, newName)); messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); messageBox.setDefaultButton(QMessageBox::Yes); messageBox.setIcon(QMessageBox::Question); @@ -93,7 +94,7 @@ bool askToUpdateInstanceDirName(InstancePtr instance, QWidget* parent) return false; // Now we can confirm that a renaming is happening - if (!instance->syncInstanceDirName()) { + if (!instance->syncInstanceDirName(newRoot)) { QMessageBox::warning(parent, QObject::tr("Cannot rename instance"), QObject::tr("An error occurred when performing the following renaming operation:
" " - Old instance root: %1
"