summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-12-14 19:26:50 +0100
committerPetr Mrázek <peterix@gmail.com>2013-12-14 19:26:50 +0100
commitd15a6490f6f2d6b1252fc48feaaba9dd89608569 (patch)
treee8fba87f96d46a83360445bfe4cc0822aa25a294
parentf15306a0ac0b9e449344da07fd6304c5704c0913 (diff)
downloadMultiMC-d15a6490f6f2d6b1252fc48feaaba9dd89608569.tar
MultiMC-d15a6490f6f2d6b1252fc48feaaba9dd89608569.tar.gz
MultiMC-d15a6490f6f2d6b1252fc48feaaba9dd89608569.tar.lz
MultiMC-d15a6490f6f2d6b1252fc48feaaba9dd89608569.tar.xz
MultiMC-d15a6490f6f2d6b1252fc48feaaba9dd89608569.zip
Fix bugs introduced by unit test branch
Account json was getting rewritten by a folder Missing icon on Windows (hopefully fixed, `doing it live`)
-rw-r--r--CMakeLists.txt4
-rw-r--r--logic/auth/MojangAccountList.cpp17
2 files changed, 12 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ea5803d..b3e89fc1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -482,10 +482,10 @@ QT5_ADD_RESOURCES(GENERATED_QRC ${CMAKE_CURRENT_BINARY_DIR}/generated.qrc)
QT5_ADD_RESOURCES(GRAPHICS_QRC graphics.qrc)
# Add common library
-ADD_LIBRARY(MultiMC_common STATIC ${MULTIMC_SOURCES} ${MULTIMC_UI} ${GENERATED_QRC} ${GRAPHICS_QRC} ${MULTIMC_RCS})
+ADD_LIBRARY(MultiMC_common STATIC ${MULTIMC_SOURCES} ${MULTIMC_UI} ${GENERATED_QRC} ${GRAPHICS_QRC})
# Add executable
-ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32 main.cpp)
+ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32 main.cpp ${MULTIMC_RCS})
# Link
TARGET_LINK_LIBRARIES(MultiMC MultiMC_common)
diff --git a/logic/auth/MojangAccountList.cpp b/logic/auth/MojangAccountList.cpp
index 33990662..937b4721 100644
--- a/logic/auth/MojangAccountList.cpp
+++ b/logic/auth/MojangAccountList.cpp
@@ -27,6 +27,7 @@
#include "logger/QsLog.h"
#include "logic/auth/MojangAccount.h"
+#include <pathutils.h>
#define ACCOUNT_LIST_FORMAT_VERSION 2
@@ -265,11 +266,6 @@ bool MojangAccountList::loadList(const QString &filePath)
return false;
}
- if (!QDir::current().exists(path))
- {
- QDir::current().mkpath(path);
- }
-
QFile file(path);
// Try to open the file and fail if we can't.
@@ -351,9 +347,16 @@ bool MojangAccountList::saveList(const QString &filePath)
return false;
}
- if (!QDir::current().exists(path))
+ // make sure the parent folder exists
+ if(!ensureFilePathExists(path))
+ return false;
+
+ // make sure the file wasn't overwritten with a folder before (fixes a bug)
+ QFileInfo finfo(path);
+ if(finfo.isDir())
{
- QDir::current().mkpath(path);
+ QDir badDir(path);
+ badDir.removeRecursively();
}
QLOG_INFO() << "Writing account list to" << path;