From 6b4bfc3e64ff405a393be1ce8759e9447ef805a0 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 10 Feb 2023 19:28:18 +0800 Subject: [PATCH] - fix: Crash when create or open txt files in project. --- NEWS.md | 4 ++++ RedPandaIDE/editor.cpp | 4 ++-- RedPandaIDE/project.cpp | 11 +++++++++++ platform/windows/templates/Hello_ASM/main.asm | 16 +++++++--------- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/NEWS.md b/NEWS.md index 902bbe43..b1cdf96e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ Red Panda C++ Version 2.12 - fix: Can't correctly load project's custom compile options, if it contains more than one line contents. + - fix: Crash when create or open txt files in project. Red Panda C++ Version 2.11 @@ -23,6 +24,9 @@ Red Panda C++ Version 2.11 - fix: preprocessors is not correctly suggested. - fix: javadoc-style docstring is not correctly suggested - enhancement: Better syntax color for asm files. + - enhancement: Add nasm.exe in the gcc distributed with RedPanda-CPP + - enhancement: Add assembly templates + Red Panda C++ Version 2.10 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index a990d342..4e34a4f9 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -120,7 +120,7 @@ Editor::Editor(QWidget *parent, const QString& filename, } if (mProject) { - if (syntaxer->language() == QSynedit::ProgrammingLanguage::CPP) + if (syntaxer && syntaxer->language() == QSynedit::ProgrammingLanguage::CPP) mParser = mProject->cppParser(); } else { initParser(); @@ -4316,7 +4316,7 @@ void Editor::setProject(Project *pProject) return; mProject = pProject; if (mProject) { - if (syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP) { + if (syntaxer() && syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP) { mParser = mProject->cppParser(); if (isVisible()) { if (mParser && mParser->parsing()) { diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 3db5c32d..5b367801 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -948,6 +948,17 @@ bool Project::assignTemplate(const std::shared_ptr aTemplate, b cleanPath(dir.absoluteFilePath(templateUnit->Source)), includeTrailingPathDelimiter(this->directory())+target); unit = newUnit(mRootNode, target); + + FileType fileType=getFileType(unit->fileName()); + if (fileType==FileType::ASM + || isCFile(unit->fileName()) || isHFile(unit->fileName())) { + Editor * editor = mEditorList->newEditor( + unit->fileName(), + unit->encoding()==ENCODING_PROJECT?options().encoding:unit->encoding(), + this, + false); + editor->activate(); + } } else { QString s; PProjectUnit unit; diff --git a/platform/windows/templates/Hello_ASM/main.asm b/platform/windows/templates/Hello_ASM/main.asm index d4f88d5c..6a44e186 100644 --- a/platform/windows/templates/Hello_ASM/main.asm +++ b/platform/windows/templates/Hello_ASM/main.asm @@ -8,15 +8,13 @@ fmt: db "%s", 10, 0 ; The printf format, "\n",'0' section .text: main: - push rbp ; align our stack at entry - mov rbp, rsp ; use RBP as frame reference - sub rsp, 32 ; our 16-byte aligned local storage area - - mov rcx, fmt - mov rdx, msg +; the x64 calling convention requires you to allocate 32 bytes of shadow space before each call +; https://stackoverflow.com/questions/30190132/what-is-the-shadow-space-in-x64-assembly/ + sub rsp, 32 ; allocate shadow space for call + mov rcx, fmt ; first parameter + mov rdx, msg ; secodng parameter call printf + add rsp,32 ; remove shadow space mov eax,0 ; exit code - add rsp,32 ; restore stack - pop rbp ; restore stack - ret + ret \ No newline at end of file