mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-08 02:54:03 -05:00
Fix uses of QDir::separator, clean and strip root from config paths
This commit is contained in:
parent
8c6b1a1e7d
commit
bbd86673c5
|
|
@ -95,6 +95,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
|||
- Fix bug where layout json and blockdata could be saved separately leading to inconsistent data.
|
||||
- Fix crash when saving tilesets with fewer palettes than the maximum.
|
||||
- Fix projects not opening on Windows if the project filepath contains certain characters.
|
||||
- Fix custom project filepaths not converting Windows file separators.
|
||||
- Fix exported tile images containing garbage pixels after the end of the tiles.
|
||||
- Fix fully transparent pixels rendering with the incorrect color.
|
||||
- Fix the values for some config fields shuffling their order every save.
|
||||
|
|
|
|||
|
|
@ -984,7 +984,7 @@ void ProjectConfig::setFilePath(const QString &pathId, const QString &path) {
|
|||
}
|
||||
|
||||
QString ProjectConfig::getCustomFilePath(ProjectFilePath pathId) {
|
||||
return this->filePaths.value(pathId);
|
||||
return QDir::cleanPath(this->filePaths.value(pathId));
|
||||
}
|
||||
|
||||
QString ProjectConfig::getCustomFilePath(const QString &pathId) {
|
||||
|
|
@ -992,14 +992,17 @@ QString ProjectConfig::getCustomFilePath(const QString &pathId) {
|
|||
}
|
||||
|
||||
QString ProjectConfig::getFilePath(ProjectFilePath pathId) {
|
||||
const QString customPath = this->getCustomFilePath(pathId);
|
||||
QString customPath = this->getCustomFilePath(pathId);
|
||||
if (!customPath.isEmpty()) {
|
||||
// A custom filepath has been specified. If the file/folder exists, use that.
|
||||
const QString absCustomPath = this->projectDir + QDir::separator() + customPath;
|
||||
if (QFileInfo::exists(absCustomPath)) {
|
||||
const QString baseDir = this->projectDir + "/";
|
||||
if (customPath.startsWith(baseDir)) {
|
||||
customPath.remove(0, baseDir.length());
|
||||
}
|
||||
if (QFileInfo::exists(QDir::cleanPath(baseDir + customPath))) {
|
||||
return customPath;
|
||||
} else {
|
||||
logError(QString("Custom project filepath '%1' not found. Using default.").arg(absCustomPath));
|
||||
logError(QString("Custom project filepath '%1' not found. Using default.").arg(customPath));
|
||||
}
|
||||
}
|
||||
return defaultPaths.contains(pathId) ? defaultPaths[pathId].second : QString();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
CustomScriptsEditor::CustomScriptsEditor(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::CustomScriptsEditor),
|
||||
baseDir(userConfig.projectDir + QDir::separator())
|
||||
baseDir(userConfig.projectDir + "/")
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(QWidget *parent, Project *project)
|
|||
QMainWindow(parent),
|
||||
ui(new Ui::ProjectSettingsEditor),
|
||||
project(project),
|
||||
baseDir(projectConfig.projectDir + QDir::separator())
|
||||
baseDir(projectConfig.projectDir + "/")
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
|
@ -388,7 +388,7 @@ QString ProjectSettingsEditor::chooseProjectFile(const QString &defaultFilepath)
|
|||
QString path;
|
||||
if (defaultFilepath.endsWith("/")){
|
||||
// Default filepath is a folder, choose a new folder
|
||||
path = FileDialog::getExistingDirectory(this, "Choose Project File Folder", startDir) + QDir::separator();
|
||||
path = FileDialog::getExistingDirectory(this, "Choose Project File Folder", startDir) + "/";
|
||||
} else{
|
||||
// Default filepath is not a folder, choose a new file
|
||||
path = FileDialog::getOpenFileName(this, "Choose Project File", startDir);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user