- fix: If project's compiler set is not the same with the default compiler set, parser for the project doesn't use the project's compiler set

- fix: If project's compiler set is not the same with the default compiler set, auto openned project's file will use wrong compiler set to do syntax check.
This commit is contained in:
Roy Qu 2022-01-18 12:41:11 +08:00
parent 7602f3e6be
commit 532ba4917e
5 changed files with 30 additions and 13 deletions

View File

@ -1,6 +1,8 @@
Red Panda C++ Version 0.13.3 Red Panda C++ Version 0.13.3
- enhancement: restore editor position after rename symbol - enhancement: restore editor position after rename symbol
- enhancement: restore editor position after reformat code - enhancement: restore editor position after reformat code
- fix: If project's compiler set is not the same with the default compiler set, parser for the project doesn't use the project's compiler set
- fix: If project's compiler set is not the same with the default compiler set, auto openned project's file will use wrong compiler set to do syntax check.
Red Panda C++ Version 0.13.2 Red Panda C++ Version 0.13.2
- fix: "delete and exit" button in the environtment / folder option page doesn't work correctly - fix: "delete and exit" button in the environtment / folder option page doesn't work correctly

View File

@ -975,10 +975,15 @@ void MainWindow::openFile(const QString &filename, QTabWidget* page)
} }
try { try {
pSettings->history().removeFile(filename); pSettings->history().removeFile(filename);
editor = mEditorList->newEditor(filename,ENCODING_AUTO_DETECT, PProjectUnit unit;
false, false, page);
if (mProject) { if (mProject) {
mProject->associateEditor(editor); unit = mProject->findUnitByFilename(filename);
}
bool inProject = (mProject && unit);
editor = mEditorList->newEditor(filename,ENCODING_AUTO_DETECT,
inProject, false, page);
if (mProject) {
mProject->associateEditorToUnit(editor,unit);
} }
editor->activate(); editor->activate();
this->updateForEncodingInfo(); this->updateForEncodingInfo();
@ -1894,7 +1899,7 @@ void MainWindow::scanActiveProject(bool parse)
return; return;
//UpdateClassBrowsing; //UpdateClassBrowsing;
if (parse) { if (parse) {
resetCppParser(mProject->cppParser()); resetCppParser(mProject->cppParser(),mProject->options().compilerSet);
mProject->resetParserProjectFiles(); mProject->resetParserProjectFiles();
parseFileList(mProject->cppParser()); parseFileList(mProject->cppParser());
} else { } else {
@ -2001,12 +2006,20 @@ void MainWindow::loadLastOpens()
page = mEditorList->leftPageWidget(); page = mEditorList->leftPageWidget();
else else
page = mEditorList->rightPageWidget(); page = mEditorList->rightPageWidget();
Editor * editor = mEditorList->newEditor(editorFilename,ENCODING_AUTO_DETECT,false,false,page); PProjectUnit unit;
if (mProject) {
unit = mProject->findUnitByFilename(editorFilename);
}
bool inProject = (mProject && unit);
Editor * editor = mEditorList->newEditor(editorFilename,ENCODING_AUTO_DETECT,inProject,false,page);
if (mProject) {
mProject->associateEditorToUnit(editor,unit);
}
if (!editor) if (!editor)
continue; continue;
if (mProject) { // if (mProject) {
mProject->associateEditor(editor); // mProject->associateEditor(editor);
} // }
BufferCoord pos; BufferCoord pos;
pos.Char = lastOpenIni.GetLongValue(sectionName,"CursorCol", 1); pos.Char = lastOpenIni.GetLongValue(sectionName,"CursorCol", 1);
pos.Line = lastOpenIni.GetLongValue(sectionName,"CursorRow", 1); pos.Line = lastOpenIni.GetLongValue(sectionName,"CursorRow", 1);
@ -2742,7 +2755,6 @@ void MainWindow::openShell(const QString &folder, const QString &shellCommand)
QProcess process; QProcess process;
process.setWorkingDirectory(folder); process.setWorkingDirectory(folder);
process.setProgram(shellCommand); process.setProgram(shellCommand);
qDebug()<<shellCommand;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
process.setCreateProcessArgumentsModifier([](QProcess::CreateProcessArguments * args){ process.setCreateProcessArgumentsModifier([](QProcess::CreateProcessArguments * args){
args->flags |= CREATE_NEW_CONSOLE; args->flags |= CREATE_NEW_CONSOLE;

View File

@ -47,7 +47,6 @@ Project::Project(const QString &filename, const QString &name, QObject *parent)
std::bind( std::bind(
&EditorList::getContentFromOpenedEditor,pMainWindow->editorList(), &EditorList::getContentFromOpenedEditor,pMainWindow->editorList(),
std::placeholders::_1, std::placeholders::_2)); std::placeholders::_1, std::placeholders::_2));
resetCppParser(mParser);
if (name == DEV_INTERNAL_OPEN) { if (name == DEV_INTERNAL_OPEN) {
open(); open();
mModified = false; mModified = false;
@ -59,6 +58,7 @@ Project::Project(const QString &filename, const QString &name, QObject *parent)
ini.SaveFile(mFilename.toLocal8Bit()); ini.SaveFile(mFilename.toLocal8Bit());
mNode = makeProjectNode(); mNode = makeProjectNode();
} }
resetCppParser(mParser,mOptions.compilerSet);
} }
Project::~Project() Project::~Project()

View File

@ -586,7 +586,7 @@ void stringsToFile(const QStringList &list, const QString &fileName)
} }
} }
void resetCppParser(std::shared_ptr<CppParser> parser) void resetCppParser(std::shared_ptr<CppParser> parser, int compilerSetIndex)
{ {
if (!parser) if (!parser)
return; return;
@ -600,7 +600,10 @@ void resetCppParser(std::shared_ptr<CppParser> parser)
parser->setParseLocalHeaders(true); parser->setParseLocalHeaders(true);
// Set options depending on the current compiler set // Set options depending on the current compiler set
// TODO: do this every time OnCompilerSetChanged // TODO: do this every time OnCompilerSetChanged
Settings::PCompilerSet compilerSet = pSettings->compilerSets().defaultSet(); if (compilerSetIndex<-1) {
compilerSetIndex=pSettings->compilerSets().defaultIndex();
}
Settings::PCompilerSet compilerSet = pSettings->compilerSets().getSet(compilerSetIndex);
parser->clearIncludePaths(); parser->clearIncludePaths();
if (compilerSet) { if (compilerSet) {
foreach (const QString& file,compilerSet->CppIncludeDirs()) { foreach (const QString& file,compilerSet->CppIncludeDirs()) {

View File

@ -229,7 +229,7 @@ bool readRegistry(HKEY key,const QByteArray& subKey, const QByteArray& name, QSt
#endif #endif
class CppParser; class CppParser;
void resetCppParser(std::shared_ptr<CppParser> parser); void resetCppParser(std::shared_ptr<CppParser> parser, int compilerSetIndex=-1);
float desktopDpi(); float desktopDpi();
float pointToPixel(float point); float pointToPixel(float point);