From 08fdeca21910a71188424610398d4641e8131a33 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 13 Feb 2023 19:21:11 +0800 Subject: [PATCH] - fix: Can't compile files with chinese characters in filenames using winlibs mingw gcc --- NEWS.md | 1 + RedPandaIDE/compiler/compiler.cpp | 2 +- RedPandaIDE/compiler/projectcompiler.cpp | 18 +++++++++--------- RedPandaIDE/mainwindow.cpp | 20 ++++++++++---------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/NEWS.md b/NEWS.md index 389df751..62b60a95 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,6 +16,7 @@ Red Panda C++ Version 2.12 - enhancement: New GAS File in the File Menu - change: rename "New File" to "New C/C++ File" - change: The default disassemble style of CPU Dialog is "AT&T" now. + - fix: Can't compile files with chinese characters in filenames using winlibs mingw gcc Red Panda C++ Version 2.11 diff --git a/RedPandaIDE/compiler/compiler.cpp b/RedPandaIDE/compiler/compiler.cpp index 5a754ae2..d7d8f112 100644 --- a/RedPandaIDE/compiler/compiler.cpp +++ b/RedPandaIDE/compiler/compiler.cpp @@ -665,7 +665,7 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q } env.insert("PATH",path); } - env.insert("LANG","en"); + //env.insert("LANG","en"); env.insert("LDFLAGS","-Wl,--stack,12582912"); env.insert("CFLAGS",""); env.insert("CXXFLAGS",""); diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index 7eea734f..fdf934f4 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -55,9 +55,9 @@ void ProjectCompiler::createStandardMakeFile() file.write("$(BIN): $(OBJ)\n"); if (!mOnlyCheckSyntax) { if (mProject->options().isCpp) { - writeln(file,"\t$(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)"); + writeln(file,"\t$(CPP) $(LINKOBJ) -o \"$(BIN)\" $(LIBS)"); } else - writeln(file,"\t$(CC) $(LINKOBJ) -o $(BIN) $(LIBS)"); + writeln(file,"\t$(CC) $(LINKOBJ) -o \"$(BIN)\" $(LIBS)"); } writeMakeObjFilesRules(file); } @@ -81,9 +81,9 @@ void ProjectCompiler::createDynamicMakeFile() writeln(file,"$(BIN): $(LINKOBJ)"); if (!mOnlyCheckSyntax) { if (mProject->options().isCpp) { - writeln(file, "\t$(CPP) -mdll $(LINKOBJ) -o $(BIN) $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)"); + writeln(file, "\t$(CPP) -mdll $(LINKOBJ) -o \"$(BIN)\" $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)"); } else { - writeln(file, "\t$(CC) -mdll $(LINKOBJ) -o $(BIN) $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)"); + writeln(file, "\t$(CC) -mdll $(LINKOBJ) -o \"$(BIN)\" $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)"); } } writeMakeObjFilesRules(file); @@ -494,17 +494,17 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file) writeln(file, "\t(CC) -c " + genMakePath1(shortFileName) + " $(CFLAGS) " + encodingStr); } else { if (unit->compileCpp()) - writeln(file, "\t$(CPP) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CXXFLAGS) " + encodingStr); + writeln(file, "\t$(CPP) -c " + genMakePath1(shortFileName) + " -o \"" + objFileName2 + "\" $(CXXFLAGS) " + encodingStr); else - writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CFLAGS) " + encodingStr); + writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o \"" + objFileName2 + "\" $(CFLAGS) " + encodingStr); } } else if (fileType==FileType::GAS) { if (!mOnlyCheckSyntax) { - writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CFLAGS) " + encodingStr); + writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o \"" + objFileName2 + "\" $(CFLAGS) " + encodingStr); } } else if (fileType==FileType::ASM) { if (!mOnlyCheckSyntax) { - writeln(file, "\t$(ASM) " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(ASMFLAGS) "); + writeln(file, "\t$(ASM) " + genMakePath1(shortFileName) + " -o \"" + objFileName2 + "\" $(ASMFLAGS) "); } } } @@ -561,7 +561,7 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file) } else { writeln(file); writeln(file, objFileName2 + ": " + privResName2 + ' ' + resFiles); - writeln(file, "\t$(WINDRES) -i " + privResName + windresArgs + " --input-format=rc -o " + objFileName + " -O coff $(WINDRESFLAGS)" + writeln(file, "\t$(WINDRES) -i " + privResName + windresArgs + " --input-format=rc -o \"" + objFileName + "\" -O coff $(WINDRESFLAGS)" + ResIncludes); } writeln(file); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 13da75e9..0c8c7859 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -3021,16 +3021,6 @@ void MainWindow::onBookmarkContextMenu(const QPoint &pos) bool MainWindow::saveLastOpens() { QString filename = includeTrailingPathDelimiter(pSettings->dirs().config()) + DEV_LASTOPENS_FILE; - QFile file(filename); - - if (!file.open(QFile::WriteOnly | QFile::Truncate)) { - QMessageBox::critical(this, - tr("Save last open info error"), - tr("Can't open last open information file '%1' for write!") - .arg(filename), - QMessageBox::Ok); - return true; - } QJsonObject rootObj; if (mProject) { rootObj["lastProject"]=mProject->filename(); @@ -3071,6 +3061,16 @@ bool MainWindow::saveLastOpens() QJsonDocument doc; doc.setObject(rootObj); QByteArray json = doc.toJson(); + QFile file(filename); + + if (!file.open(QFile::WriteOnly | QFile::Truncate)) { + QMessageBox::critical(this, + tr("Save last open info error"), + tr("Can't open last open information file '%1' for write!") + .arg(filename), + QMessageBox::Ok); + return true; + } if (file.write(doc.toJson())!=json.count()) { QMessageBox::critical(this, tr("Save last open info error"),