- 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
- 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

View File

@ -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()<<shellCommand;
#ifdef Q_OS_WIN
process.setCreateProcessArgumentsModifier([](QProcess::CreateProcessArguments * args){
args->flags |= CREATE_NEW_CONSOLE;

View File

@ -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()

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)
return;
@ -600,7 +600,10 @@ void resetCppParser(std::shared_ptr<CppParser> 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()) {

View File

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