summaryrefslogtreecommitdiff
path: root/src/installationmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/installationmanager.cpp')
-rw-r--r--src/installationmanager.cpp48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp
index eb788a9c..7d431f02 100644
--- a/src/installationmanager.cpp
+++ b/src/installationmanager.cpp
@@ -62,16 +62,17 @@ template <typename T>
static T resolveFunction(QLibrary &lib, const char *name)
{
T temp = reinterpret_cast<T>(lib.resolve(name));
- if (temp == NULL) {
+ if (temp == nullptr) {
throw std::runtime_error(QObject::tr("invalid 7-zip32.dll: %1").arg(lib.errorString()).toLatin1().constData());
}
return temp;
}
-InstallationManager::InstallationManager(QWidget *parent)
- : QObject(parent), m_ParentWidget(parent),
- m_InstallationProgress(parent), m_SupportedExtensions(boost::assign::list_of("zip")("rar")("7z")("fomod")("001"))
+InstallationManager::InstallationManager()
+ : m_ParentWidget(nullptr)
+ , m_InstallationProgress(nullptr)
+ , m_SupportedExtensions({ "zip", "rar", "7z", "fomod", "001" })
{
QLibrary archiveLib("dlls\\archive.dll");
if (!archiveLib.load()) {
@@ -94,10 +95,18 @@ InstallationManager::~InstallationManager()
delete m_CurrentArchive;
}
+void InstallationManager::setParentWidget(QWidget *widget)
+{
+ m_InstallationProgress.setParent(widget, Qt::Dialog);
+ for (IPluginInstaller *installer : m_Installers) {
+ installer->setParentWidget(widget);
+ }
+}
+
void InstallationManager::queryPassword(LPSTR password)
{
- QString result = QInputDialog::getText(NULL, tr("Password required"), tr("Password"), QLineEdit::Password);
+ QString result = QInputDialog::getText(nullptr, tr("Password required"), tr("Password"), QLineEdit::Password);
strncpy(password, result.toLocal8Bit().constData(), MAX_PASSWORD_LENGTH);
}
@@ -225,10 +234,10 @@ QStringList InstallationManager::extractFiles(const QStringList &filesOrig, bool
const wchar_t *targetFile = data[i]->getFileName();
if (flatten) {
targetFile = wcsrchr(data[i]->getFileName(), '\\');
- if (targetFile == NULL) {
+ if (targetFile == nullptr) {
targetFile = wcsrchr(data[i]->getFileName(), '/');
}
- if (targetFile == NULL) {
+ if (targetFile == nullptr) {
qCritical("failed to find backslash in %ls", data[i]->getFileName());
continue;
} else {
@@ -377,7 +386,7 @@ DirectoryTree::Node *InstallationManager::getSimpleArchiveBase(DirectoryTree *da
currentNode = *currentNode->nodesBegin();
} else {
qDebug("not a simple archive");
- return NULL;
+ return nullptr;
}
}
}
@@ -433,7 +442,6 @@ QString InstallationManager::generateBackupName(const QString &directoryName) co
bool InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *merge) const
{
QString targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory + "\\" + modName);
-
while (QDir(targetDirectory).exists()) {
QueryOverwriteDialog overwriteDialog(m_ParentWidget);
if (overwriteDialog.exec()) {
@@ -636,7 +644,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString>
int categoryID = 0;
QString repository = "Nexus";
- QString metaName = fileName.mid(0).append(".meta");
+ QString metaName = fileName + ".meta";
if (QFile(metaName).exists()) {
QSettings metaFile(metaName, QSettings::IniFormat);
modID = metaFile.value("modID", 0).toInt();
@@ -681,7 +689,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString>
}
ON_BLOCK_EXIT(std::bind(&InstallationManager::postInstallCleanup, this));
- QScopedPointer<DirectoryTree> filesTree(archiveOpen ? createFilesTree() : NULL);
+ QScopedPointer<DirectoryTree> filesTree(archiveOpen ? createFilesTree() : nullptr);
IPluginInstaller::EInstallResult installResult = IPluginInstaller::RESULT_NOTATTEMPTED;
std::sort(m_Installers.begin(), m_Installers.end(), [] (IPluginInstaller *LHS, IPluginInstaller *RHS) {
@@ -689,8 +697,8 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString>
});
foreach (IPluginInstaller *installer, m_Installers) {
- // don't use inactive installers
- if (!installer->isActive()) {
+ // don't use inactive installers (installer can't be null here but vc static code analysis thinks it could)
+ if ((installer == nullptr) || !installer->isActive()) {
continue;
}
@@ -706,8 +714,8 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString>
try {
{ // simple case
IPluginInstallerSimple *installerSimple = dynamic_cast<IPluginInstallerSimple*>(installer);
- if ((installerSimple != NULL) &&
- (filesTree != NULL) && (installer->isArchiveSupported(*filesTree))) {
+ if ((installerSimple != nullptr) &&
+ (filesTree != nullptr) && (installer->isArchiveSupported(*filesTree))) {
installResult = installerSimple->install(modName, *filesTree, version, modID);
if (installResult == IPluginInstaller::RESULT_SUCCESS) {
mapToArchive(filesTree.data());
@@ -721,9 +729,9 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString>
{ // custom case
IPluginInstallerCustom *installerCustom = dynamic_cast<IPluginInstallerCustom*>(installer);
- if ((installerCustom != NULL) &&
- (((filesTree != NULL) && installer->isArchiveSupported(*filesTree)) ||
- ((filesTree == NULL) && installerCustom->isArchiveSupported(fileName)))) {
+ if ((installerCustom != nullptr) &&
+ (((filesTree != nullptr) && installer->isArchiveSupported(*filesTree)) ||
+ ((filesTree == nullptr) && installerCustom->isArchiveSupported(fileName)))) {
std::set<QString> installerExtensions = installerCustom->supportedExtensions();
if (installerExtensions.find(fileInfo.suffix()) != installerExtensions.end()) {
installResult = installerCustom->install(modName, fileName, version, modID);
@@ -749,7 +757,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString>
} break;
case IPluginInstaller::RESULT_SUCCESS:
case IPluginInstaller::RESULT_SUCCESSCANCEL: {
- if (filesTree != NULL) {
+ if (filesTree != nullptr) {
DirectoryTree::node_iterator iniTweakNode = filesTree->nodeFind(DirectoryTreeInformation("INI Tweaks"));
hasIniTweaks = (iniTweakNode != filesTree->nodesEnd()) &&
((*iniTweakNode)->numLeafs() != 0);
@@ -807,7 +815,7 @@ void InstallationManager::registerInstaller(IPluginInstaller *installer)
m_Installers.push_back(installer);
installer->setInstallationManager(this);
IPluginInstallerCustom *installerCustom = dynamic_cast<IPluginInstallerCustom*>(installer);
- if (installerCustom != NULL) {
+ if (installerCustom != nullptr) {
std::set<QString> extensions = installerCustom->supportedExtensions();
m_SupportedExtensions.insert(extensions.begin(), extensions.end());
}