fix: If a project is auto openned when start, close app will cause dead lock.
This commit is contained in:
parent
0875d15d67
commit
82bbd7a846
|
@ -975,9 +975,11 @@ void MainWindow::openFile(const QString &filename, QTabWidget* page)
|
|||
}
|
||||
try {
|
||||
pSettings->history().removeFile(filename);
|
||||
bool inProject = (mProject && mProject->isProjectUnit(filename));
|
||||
editor = mEditorList->newEditor(filename,ENCODING_AUTO_DETECT,
|
||||
inProject, false, page);
|
||||
false, false, page);
|
||||
if (mProject) {
|
||||
mProject->associateEditor(editor);
|
||||
}
|
||||
editor->activate();
|
||||
this->updateForEncodingInfo();
|
||||
} catch (FileError e) {
|
||||
|
@ -1041,13 +1043,7 @@ void MainWindow::openProject(const QString &filename, bool openFiles)
|
|||
for (int i=0;i<mProject->units().count();i++) {
|
||||
PProjectUnit unit = mProject->units()[i];
|
||||
Editor* e = mEditorList->getOpenedEditorByFilename(unit->fileName());
|
||||
if (e) {
|
||||
unit->setEditor(e);
|
||||
unit->setEncoding(e->encodingOption());
|
||||
e->setInProject(true);
|
||||
} else {
|
||||
unit->setEditor(nullptr);
|
||||
}
|
||||
mProject->associateEditorToUnit(e,unit);
|
||||
}
|
||||
|
||||
Editor * e = mEditorList->getEditor();
|
||||
|
@ -2005,10 +2001,12 @@ void MainWindow::loadLastOpens()
|
|||
page = mEditorList->leftPageWidget();
|
||||
else
|
||||
page = mEditorList->rightPageWidget();
|
||||
bool inProject = (mProject && mProject->isProjectUnit(editorFilename));
|
||||
Editor * editor = mEditorList->newEditor(editorFilename,ENCODING_AUTO_DETECT,inProject,false,page);
|
||||
Editor * editor = mEditorList->newEditor(editorFilename,ENCODING_AUTO_DETECT,false,false,page);
|
||||
if (!editor)
|
||||
continue;
|
||||
if (mProject) {
|
||||
mProject->associateEditor(editor);
|
||||
}
|
||||
BufferCoord pos;
|
||||
pos.Char = lastOpenIni.GetLongValue(sectionName,"CursorCol", 1);
|
||||
pos.Line = lastOpenIni.GetLongValue(sectionName,"CursorRow", 1);
|
||||
|
|
|
@ -564,13 +564,34 @@ bool Project::saveUnits()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Project::isProjectUnit(const QString &filename)
|
||||
PProjectUnit Project::findUnitByFilename(const QString &filename)
|
||||
{
|
||||
foreach(const PProjectUnit& unit, mUnits) {
|
||||
foreach(PProjectUnit unit, mUnits) {
|
||||
if (QString::compare(unit->fileName(),filename, PATH_SENSITIVITY)==0)
|
||||
return true;
|
||||
return unit;
|
||||
}
|
||||
return PProjectUnit();
|
||||
}
|
||||
|
||||
void Project::associateEditor(Editor *editor)
|
||||
{
|
||||
if (!editor)
|
||||
return;
|
||||
PProjectUnit unit = findUnitByFilename(editor->filename());
|
||||
associateEditorToUnit(editor,unit);
|
||||
}
|
||||
|
||||
void Project::associateEditorToUnit(Editor *editor, PProjectUnit unit)
|
||||
{
|
||||
if (!unit)
|
||||
return;
|
||||
if (editor) {
|
||||
unit->setEditor(editor);
|
||||
unit->setEncoding(editor->encodingOption());
|
||||
editor->setInProject(true);
|
||||
} else {
|
||||
unit->setEditor(nullptr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Project::setCompilerOption(const QString &optionString, char value)
|
||||
|
|
|
@ -184,7 +184,9 @@ public:
|
|||
void saveUnitAs(int i, const QString& sFileName, bool syncEditor = true); // save single [UnitX]
|
||||
void saveUnitLayout(Editor* e, int index); // save single [UnitX] cursor positions
|
||||
bool saveUnits();
|
||||
bool isProjectUnit(const QString& filename);
|
||||
PProjectUnit findUnitByFilename(const QString& filename);
|
||||
void associateEditor(Editor* editor);
|
||||
void associateEditorToUnit(Editor* editor, PProjectUnit unit);
|
||||
void setCompilerOption(const QString& optionString, char value);
|
||||
void sortUnitsByPriority();
|
||||
void sortUnitsByAlpha();
|
||||
|
|
Loading…
Reference in New Issue