- fix: crash when load last opens

- enhancement: when a system/project header file is saved to non-system folders, un-readonly the editor
 - minor speedup when processing tooltips
This commit is contained in:
royqh1979@gmail.com 2021-09-28 10:01:13 +08:00
parent 0424f7cf45
commit 3afe034aa1
7 changed files with 27 additions and 9 deletions

View File

@ -1,3 +1,6 @@
Version 0.2.1
- fix: crash when load last opens
Version 0.2
- fix : header file completion stop work when input '.'
- change: continue to run / debug if there are compiling warnings (but no errors)

View File

@ -376,7 +376,7 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
foreach(const PProjectUnit& unit, mProject->units()) {
if (getFileType(unit->fileName())!=FileType::WindowsResourceSource)
continue;
if (QFile(unit->fileName()).exists()) {
if (fileExists(unit->fileName())) {
QString ResFile = extractRelativePath(mProject->makeFileName(), unit->fileName());
ResFiles = ResFiles + genMakePath2(ResFile) + ' ';
}

View File

@ -110,7 +110,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
}
if (pSettings->editor().readOnlySytemHeader()
&& (mParser->isSystemHeaderFile(filename) || mParser->isProjectHeaderFile(filename))) {
&& (mParser->isSystemHeaderFile(mFilename) || mParser->isProjectHeaderFile(mFilename))) {
this->setModified(false);
setReadOnly(true);
updateCaption();
@ -316,6 +316,11 @@ bool Editor::saveAs(const QString &name, bool fromProject){
if (pSettings->editor().syntaxCheckWhenSave())
pMainWindow->checkSyntaxInBack(this);
if (pSettings->editor().readOnlySytemHeader()
&& (!mParser->isSystemHeaderFile(mFilename) && !mParser->isProjectHeaderFile(mFilename))) {
setReadOnly(false);
updateCaption();
}
return true;
}
@ -681,8 +686,8 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
//selection
if (selAvail() && highlighter()) {
if ((
(attr->name() == SYNS_AttrIdentifier)
|| (attr->name() == SYNS_AttrReservedWord)
(attr == highlighter()->identifierAttribute())
|| (attr == highlighter()->keywordAttribute())
|| (attr->name() == SYNS_AttrPreprocessor)
)
&& (token == mSelectionWord)) {
@ -694,7 +699,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
// qDebug()<<token<<"-"<<attr->name()<<" - "<<line<<" : "<<aChar;
if (mParser && mCompletionPopup && (attr->name() == SYNS_AttrIdentifier)) {
if (mParser && mCompletionPopup && (attr == highlighter()->identifierAttribute())) {
BufferCoord p{aChar,line};
BufferCoord pBeginPos,pEndPos;
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
@ -2125,7 +2130,7 @@ Editor::TipType Editor::getTipType(QPoint point, BufferCoord& pos)
// do not allow when dragging selection
if (isPointInSelection(pos))
return TipType::Selection;
} else if (attr->name() == SYNS_AttrIdentifier)
} else if (attr == highlighter()->identifierAttribute())
return TipType::Identifier;
else if (attr->name() == SYNS_AttrPreprocessor)
return TipType::Preprocessor;
@ -2388,7 +2393,7 @@ void Editor::updateFunctionTip()
pMainWindow->functionTip()->hide();
return;
}
if (HLAttr->name()!=SYNS_AttrIdentifier) {
if (HLAttr != highlighter()->identifierAttribute()) {
pMainWindow->functionTip()->hide();
return;
}

View File

@ -29,7 +29,7 @@ Editor* EditorList::newEditor(const QString& filename, const QByteArray& encodin
parentPageControl = getNewEditorPageControl();
else
parentPageControl = page;
if (!filename.isEmpty() && QFile(filename).exists()) {
if (fileExists(filename)) {
pMainWindow->fileSystemWatcher()->addPath(filename);
}
Editor * e = new Editor(parentPageControl,filename,encoding,inProject,newFile,parentPageControl);
@ -255,6 +255,8 @@ void EditorList::forceCloseEditor(Editor *editor)
Editor* EditorList::getOpenedEditorByFilename(const QString &filename)
{
if (filename.isEmpty())
return nullptr;
QFileInfo fileInfo(filename);
QString fullname = fileInfo.absoluteFilePath();
for (int i=0;i<mLeftPageWidget->count();i++) {
@ -274,6 +276,8 @@ Editor* EditorList::getOpenedEditorByFilename(const QString &filename)
Editor *EditorList::getEditorByFilename(const QString &filename)
{
if (filename.isEmpty())
return nullptr;
//check if an editor is already openned
Editor* e=getOpenedEditorByFilename(filename);
if (e!=nullptr)

View File

@ -1536,7 +1536,7 @@ void MainWindow::loadLastOpens()
updateEditorActions();
updateForEncodingInfo();
}
if (!focusedEditor)
if (focusedEditor)
focusedEditor->activate();
}

View File

@ -356,6 +356,8 @@ QString getSystemHeaderFilename(const QString &fileName, const QSet<QString>& in
bool isSystemHeaderFile(const QString &fileName, const QSet<QString> &includePaths)
{
if (fileName.isEmpty())
return false;
if (includePaths.isEmpty())
return false;
bool isFullName = false;

View File

@ -135,6 +135,8 @@ bool isNonPrintableAsciiChar(char ch)
bool fileExists(const QString &file)
{
if (file.isEmpty())
return false;
return QFile(file).exists();
}
@ -148,6 +150,8 @@ bool fileExists(const QString &dir, const QString &fileName)
bool directoryExists(const QString &file)
{
if (file.isEmpty())
return false;
QFileInfo dir(file);
return dir.exists() && dir.isDir();
}