summaryrefslogtreecommitdiff
path: root/src/modinfo.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-06-05 10:05:29 +0200
committerTannin <devnull@localhost>2013-06-05 10:05:29 +0200
commit97111de1409a59eea9e7ab5050ab70f4d01ddb8e (patch)
tree6d3ed6dd899573d23bef15adb2519173cd844b76 /src/modinfo.cpp
parent280691ebc36d34c803a5bd8e01616680b0d2fafb (diff)
parent1606c1366f5d0ba304334b0e57680fb99feb88b9 (diff)
Merge
Diffstat (limited to 'src/modinfo.cpp')
-rw-r--r--src/modinfo.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/modinfo.cpp b/src/modinfo.cpp
index a08a4ccd..e3e0487b 100644
--- a/src/modinfo.cpp
+++ b/src/modinfo.cpp
@@ -509,6 +509,7 @@ bool ModInfoRegular::setName(const QString &name)
QString newPath = m_Path.mid(0).replace(m_Path.length() - m_Name.length(), m_Name.length(), name);
QDir modDir(m_Path.mid(0, m_Path.length() - m_Name.length()));
+
if (m_Name.compare(name, Qt::CaseInsensitive) == 0) {
QString tempName = name;
tempName.append("_temp");
@@ -524,23 +525,29 @@ bool ModInfoRegular::setName(const QString &name)
return false;
}
} else {
- if (!modDir.rename(m_Name, name)) {
+ if (!shellRename(modDir.absoluteFilePath(m_Name), modDir.absoluteFilePath(name))) {
+ qCritical("failed to rename mod %s (errorcode %d)",
+ qPrintable(name), ::GetLastError());
return false;
}
}
std::map<QString, unsigned int>::iterator nameIter = s_ModsByName.find(m_Name);
- unsigned int index = nameIter->second;
- s_ModsByName.erase(nameIter);
-
- m_Name = name;
- m_Path = newPath;
+ if (nameIter != s_ModsByName.end()) {
+ unsigned int index = nameIter->second;
+ s_ModsByName.erase(nameIter);
- s_ModsByName[m_Name] = index;
+ m_Name = name;
+ m_Path = newPath;
- std::sort(s_Collection.begin(), s_Collection.end(), ByName);
+ s_ModsByName[m_Name] = index;
- updateIndices();
+ std::sort(s_Collection.begin(), s_Collection.end(), ByName);
+ updateIndices();
+ } else { // otherwise mod isn't registered yet?
+ m_Name = name;
+ m_Path = newPath;
+ }
return true;
}