diff options
| author | Tannin <sherb@gmx.net> | 2016-01-10 20:22:50 +0100 |
|---|---|---|
| committer | Tannin <sherb@gmx.net> | 2016-01-10 20:22:50 +0100 |
| commit | a9a51f50852c2a0b08b3a1aad8960991a6f01e32 (patch) | |
| tree | f01b134c629cfa82e0c82b050f24d18b0bac84b5 | |
| parent | 2aae65d6f6c1ab3309e54437a339d1644088c5c8 (diff) | |
fixed a potential crash-cause when querying download info and slight improvement (?) to the regex that extracts the modid
| -rw-r--r-- | src/downloadmanager.cpp | 23 | ||||
| -rw-r--r-- | src/nexusinterface.cpp | 2 |
2 files changed, 10 insertions, 15 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 648276ce..6b4628cc 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -693,19 +693,14 @@ void DownloadManager::queryInfo(int index) QString ignore;
NexusInterface::interpretNexusFileName(fileName, ignore, info->m_FileInfo->modID, true);
if (info->m_FileInfo->modID < 0) {
- QString modIDString;
- while (modIDString.isEmpty()) {
- modIDString = QInputDialog::getText(nullptr, tr("Please enter the nexus mod id"), tr("Mod ID:"), QLineEdit::Normal,
- QString(), nullptr, 0, Qt::ImhFormattedNumbersOnly);
- if (modIDString.isNull()) {
- // canceled
- return;
- } else if (modIDString.contains(QRegExp("[^0-9]"))) {
- qDebug("illegal character in mod-id");
- modIDString.clear();
- }
- }
- info->m_FileInfo->modID = modIDString.toInt(nullptr, 10);
+ bool ok = false;
+ int modId = QInputDialog::getInt(
+ nullptr, tr("Please enter the nexus mod id"), tr("Mod ID:"), 1, 1,
+ std::numeric_limits<int>::max(), 1, &ok);
+ // careful now: while the dialog was displayed, events were processed.
+ // the download list might have changed and our info-ptr invalidated.
+ m_ActiveDownloads[index]->m_FileInfo->modID = modId;
+ return;
}
}
info->m_ReQueried = true;
@@ -1247,7 +1242,7 @@ int DownloadManager::startDownloadURLs(const QStringList &urls) int DownloadManager::startDownloadNexusFile(int modID, int fileID)
{
int newID = m_ActiveDownloads.size();
- addNXMDownload(QString("nxm://%1/mods/%2/files/%3").arg(m_ManagedGame->getGameShortName()).arg(modID).arg(fileID));
+ addNXMDownload(QString("nxm://%1/mods/%2/files/%3").arg(m_ManagedGame->gameShortName()).arg(modID).arg(fileID));
return newID;
}
diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index b8326c80..f9d9b6bd 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -193,7 +193,7 @@ void NexusInterface::loginCompleted() void NexusInterface::interpretNexusFileName(const QString &fileName, QString &modName, int &modID, bool query)
{
//Look for something along the lines of modulename-Vn-m + any old rubbish.
- static std::regex exp("^([a-zA-Z0-9_'\"\\- ]*?)([-_ ][VvRr]?[0-9_]+)?-([1-9][0-9]+).*");
+ static std::regex exp("^([a-zA-Z0-9_'\"\\-.() ]*?)([-_ ][VvRr]?[0-9_]+)?-([1-9][0-9]+).*\.(zip|rar|7z)");
static std::regex simpleexp("^([a-zA-Z0-9_]+)");
QByteArray fileNameUTF8 = fileName.toUtf8();
|
