diff --git a/NEWS.md b/NEWS.md index 61f8985d..22fcfcb7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,8 +16,8 @@ Red Panda C++ Version 2.24 - enhancement: Support simple const expression evaluation for enum values. - fix: Accessibilty for inherited members are not correct calculated in multiple inheritance. - fix: Can't parse full class name when handle inheritance. - - fix: Can't parse virtual inherit. - + - fix: Can't parse virtual inherit. + - fix: Filename in the gcc 13.1 error messages when building project is using wrong encoding. Red Panda C++ Version 2.23 diff --git a/RedPandaIDE/compiler/compiler.cpp b/RedPandaIDE/compiler/compiler.cpp index bbf9039c..ea256097 100644 --- a/RedPandaIDE/compiler/compiler.cpp +++ b/RedPandaIDE/compiler/compiler.cpp @@ -664,6 +664,8 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q bool errorOccurred = false; process.setProgram(cmd); QString cmdDir = extractFileDir(cmd); + bool compilerErrorUTF8=compilerSet()->isCompilerInfoUsingUTF8(); + bool outputUTF8=compilerSet()->forceUTF8(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); if (!cmdDir.isEmpty()) { QString path = env.value("PATH"); @@ -682,18 +684,19 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q process.setArguments(splitProcessCommand(arguments)); process.setWorkingDirectory(workingDir); + process.connect(&process, &QProcess::errorOccurred, [&](){ errorOccurred= true; }); - process.connect(&process, &QProcess::readyReadStandardError,[&process,this](){ - if (compilerSet()->compilerType() == CompilerType::Clang) + process.connect(&process, &QProcess::readyReadStandardError,[&process,this,compilerErrorUTF8](){ + if (compilerErrorUTF8) this->error(QString::fromUtf8(process.readAllStandardError())); else this->error(QString::fromLocal8Bit( process.readAllStandardError())); }); - process.connect(&process, &QProcess::readyReadStandardOutput,[&process,this](){ - if (compilerSet()->compilerType() == CompilerType::Clang) + process.connect(&process, &QProcess::readyReadStandardOutput,[&process,this,outputUTF8](){ + if (outputUTF8) this->log(QString::fromUtf8(process.readAllStandardOutput())); else this->log(QString::fromLocal8Bit( process.readAllStandardOutput())); diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 56c130b7..d47625f7 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -84,28 +84,8 @@ bool Debugger::start(int compilerSetIndex, const QString& inferior, const QStrin tr("No compiler set is configured.")+tr("Can't start debugging.")); return false; } - setForceUTF8(CompilerInfoManager::forceUTF8InDebugger(compilerSet->compilerType())); - setDebugInfosUsingUTF8(false); -#ifdef Q_OS_WIN - - bool isOk; - int productVersion = QSysInfo::productVersion().toInt(&isOk); -// qDebug()<mainVersion()>=13 && compilerSet->compilerType()==CompilerType::GCC - && productVersion>=10) - setDebugInfosUsingUTF8(true); -#endif + setForceUTF8(compilerSet->forceUTF8()); + setDebugInfosUsingUTF8(compilerSet->isDebugInfoUsingUTF8()); if (compilerSet->debugger().endsWith(LLDB_MI_PROGRAM)) setDebuggerType(DebuggerType::LLDB_MI); else diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 1215994c..e3091a56 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -1794,7 +1794,7 @@ void Settings::CompilerSet::setCompileOptions(const QMap optio mCompileOptions=options; } -QString Settings::CompilerSet::getCompileOptionValue(const QString &key) +QString Settings::CompilerSet::getCompileOptionValue(const QString &key) const { return mCompileOptions.value(key,QString()); } @@ -2485,7 +2485,7 @@ void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType co } } -int Settings::CompilerSet::mainVersion() +int Settings::CompilerSet::mainVersion() const { int i = mVersion.indexOf('.'); if (i<0) @@ -2498,22 +2498,22 @@ int Settings::CompilerSet::mainVersion() } -bool Settings::CompilerSet::canCompileC() +bool Settings::CompilerSet::canCompileC() const { return fileExists(mCCompiler); } -bool Settings::CompilerSet::canCompileCPP() +bool Settings::CompilerSet::canCompileCPP() const { return fileExists(mCppCompiler); } -bool Settings::CompilerSet::canMake() +bool Settings::CompilerSet::canMake() const { return fileExists(mMake); } -bool Settings::CompilerSet::canDebug() +bool Settings::CompilerSet::canDebug() const { return fileExists(mDebugger); } @@ -2603,6 +2603,49 @@ bool Settings::CompilerSet::isOutputExecutable(CompilationStage stage) return stage == CompilationStage::GenerateExecutable; } +bool Settings::CompilerSet::isDebugInfoUsingUTF8() const +{ + switch(mCompilerType) { + case CompilerType::Clang: + case CompilerType::GCC_UTF8: + return true; + case CompilerType::GCC: +#ifdef Q_OS_WIN + if (mainVersion()>=13) { + bool isOk; + int productVersion = QSysInfo::productVersion().toInt(&isOk); + // qDebug()<=10; + } +#else + break; +#endif + default: + break; + } + return false; +} + +bool Settings::CompilerSet::forceUTF8() const +{ + return CompilerInfoManager::forceUTF8InDebugger(mCompilerType); +} + +bool Settings::CompilerSet::isCompilerInfoUsingUTF8() const +{ + return isDebugInfoUsingUTF8(); +} + const QString &Settings::CompilerSet::assemblingSuffix() const { return mAssemblingSuffix; diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index e6a0c92c..9ba1f7f8 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -1342,14 +1342,14 @@ public: void unsetCompileOption(const QString& key); void setCompileOptions(const QMap options); - QString getCompileOptionValue(const QString& key); + QString getCompileOptionValue(const QString& key) const; - int mainVersion(); + int mainVersion() const; - bool canCompileC(); - bool canCompileCPP(); - bool canMake(); - bool canDebug(); + bool canCompileC() const; + bool canCompileCPP() const; + bool canMake() const; + bool canDebug() const; // bool dirsValid(QString& msg); // bool validateExes(QString& msg); //properties @@ -1435,6 +1435,10 @@ public: bool isOutputExecutable(); bool isOutputExecutable(Settings::CompilerSet::CompilationStage stage); + bool isDebugInfoUsingUTF8() const; + bool forceUTF8() const; + bool isCompilerInfoUsingUTF8() const; + private: void setDirectories(const QString& binDir, CompilerType mCompilerType); //load hard defines