diff --git a/NEWS.md b/NEWS.md index 1a30826c..3bde5d5a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ Red Panda C++ Version 0.13.3 - enhancement: restore editor position after rename symbol - 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 - fix: "delete and exit" button in the environtment / folder option page doesn't work correctly diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 2a1ab9c1..a3141131 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -975,10 +975,15 @@ void MainWindow::openFile(const QString &filename, QTabWidget* page) } try { pSettings->history().removeFile(filename); - editor = mEditorList->newEditor(filename,ENCODING_AUTO_DETECT, - false, false, page); + PProjectUnit unit; 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(); this->updateForEncodingInfo(); @@ -1894,7 +1899,7 @@ void MainWindow::scanActiveProject(bool parse) return; //UpdateClassBrowsing; if (parse) { - resetCppParser(mProject->cppParser()); + resetCppParser(mProject->cppParser(),mProject->options().compilerSet); mProject->resetParserProjectFiles(); parseFileList(mProject->cppParser()); } else { @@ -2001,12 +2006,20 @@ void MainWindow::loadLastOpens() page = mEditorList->leftPageWidget(); else 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) continue; - if (mProject) { - mProject->associateEditor(editor); - } +// if (mProject) { +// mProject->associateEditor(editor); +// } BufferCoord pos; pos.Char = lastOpenIni.GetLongValue(sectionName,"CursorCol", 1); pos.Line = lastOpenIni.GetLongValue(sectionName,"CursorRow", 1); @@ -2742,7 +2755,6 @@ void MainWindow::openShell(const QString &folder, const QString &shellCommand) QProcess process; process.setWorkingDirectory(folder); process.setProgram(shellCommand); - qDebug()<flags |= CREATE_NEW_CONSOLE; diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index f4e42865..05ad43ee 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -47,7 +47,6 @@ Project::Project(const QString &filename, const QString &name, QObject *parent) std::bind( &EditorList::getContentFromOpenedEditor,pMainWindow->editorList(), std::placeholders::_1, std::placeholders::_2)); - resetCppParser(mParser); if (name == DEV_INTERNAL_OPEN) { open(); mModified = false; @@ -59,6 +58,7 @@ Project::Project(const QString &filename, const QString &name, QObject *parent) ini.SaveFile(mFilename.toLocal8Bit()); mNode = makeProjectNode(); } + resetCppParser(mParser,mOptions.compilerSet); } Project::~Project() diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index ab0ed3ce..ae9d4525 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -586,7 +586,7 @@ void stringsToFile(const QStringList &list, const QString &fileName) } } -void resetCppParser(std::shared_ptr parser) +void resetCppParser(std::shared_ptr parser, int compilerSetIndex) { if (!parser) return; @@ -600,7 +600,10 @@ void resetCppParser(std::shared_ptr parser) parser->setParseLocalHeaders(true); // Set options depending on the current compiler set // 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(); if (compilerSet) { foreach (const QString& file,compilerSet->CppIncludeDirs()) { diff --git a/RedPandaIDE/utils.h b/RedPandaIDE/utils.h index c31c5488..fee53bab 100644 --- a/RedPandaIDE/utils.h +++ b/RedPandaIDE/utils.h @@ -229,7 +229,7 @@ bool readRegistry(HKEY key,const QByteArray& subKey, const QByteArray& name, QSt #endif class CppParser; -void resetCppParser(std::shared_ptr parser); +void resetCppParser(std::shared_ptr parser, int compilerSetIndex=-1); float desktopDpi(); float pointToPixel(float point);