From e98795955118a241566dd6f4b85adfe4c5eba2d0 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 28 Oct 2022 12:43:47 +0800 Subject: [PATCH] - add default autolink for fmtlib in Windows - reduce size of the executable of win-git-askpass tool - fix: memory size not correctly calculated when check if share parser. - fix: c/c++ file use different parser for share. --- NEWS.md | 3 +- RedPandaIDE/editor.cpp | 2 +- RedPandaIDE/resources/autolink.json | 4 +++ RedPandaIDE/settings.cpp | 31 ++++++++++++------- libs/redpanda_qt_utils/qt_utils/utils.cpp | 2 +- .../redpanda-win-git-askpass.pro | 12 ++----- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/NEWS.md b/NEWS.md index 32c97169..a7cfe6c5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,8 @@ Red Panda C++ Version 2.1 - enhancement: add "editors share one code parser" in "options" / "editor" / "code completion", to reduce memory usage. Turned off by default on PCs with memory > 4G; Force turned on PCs with memory < 1G. - enhancement: add "goto block start"/"goto block end" in "Code" menu - + - add fmtlib to the gcc compiler's lib distributed with RedPanda IDE windows version + - add default autolink for fmtlib in Windows Red Panda C++ Version 2.0 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index aece95f1..ef2eb6fd 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -3953,7 +3953,7 @@ PCppParser Editor::sharedParser(ParserLanguage language) { PCppParser parser; if (mSharedParsers.contains(language)) { - std::weak_ptr weakParser=mSharedParsers[language].lock(); + parser=mSharedParsers[language].lock(); } if (!parser) { parser=std::make_shared(); diff --git a/RedPandaIDE/resources/autolink.json b/RedPandaIDE/resources/autolink.json index 4a9b53c2..12a7f324 100644 --- a/RedPandaIDE/resources/autolink.json +++ b/RedPandaIDE/resources/autolink.json @@ -27,6 +27,10 @@ "header": "ege.h", "links": "-lgraphics -luuid -lmsimg32 -lgdi32 -limm32 -lole32 -loleaut32 -lwinmm -lgdiplus" }, + { + "header": "fmt/core.h", + "links": "-lfmt" + }, { "execUseUTF8": true, "header": "raylib.h", diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 6bade520..59441523 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -3695,9 +3695,16 @@ bool Settings::CodeCompletion::clearWhenEditorHidden() { MEMORYSTATUSEX statex; #ifdef Q_OS_WIN + statex.dwLength = sizeof (statex); + + GlobalMemoryStatusEx (&statex); if (statex.ullTotalPhys < (long long int)2*1024*1024*1024) { mClearWhenEditorHidden = true; } + + if (statex.ullAvailPhys < (long long int)2*1024*1024*1024) { + return true; + } #endif return mClearWhenEditorHidden; } @@ -3732,9 +3739,17 @@ bool Settings::CodeCompletion::shareParser() #ifdef Q_OS_WIN MEMORYSTATUSEX statex; + statex.dwLength = sizeof (statex); + + GlobalMemoryStatusEx (&statex); + if (statex.ullTotalPhys < (long long int)1024*1024*1024) { mShareParser = true; } + + if (statex.ullAvailPhys < (long long int)1*1024*1024*1024) { + return true; + } #endif return mShareParser; } @@ -3906,6 +3921,7 @@ void Settings::CodeCompletion::doLoad() mHideSymbolsStartsWithUnderLine = boolValue("hide_symbols_start_with_underline", false); bool doClear = true; + bool shouldShare=true; #ifdef Q_OS_WIN MEMORYSTATUSEX statex; @@ -3913,24 +3929,15 @@ void Settings::CodeCompletion::doLoad() statex.dwLength = sizeof (statex); GlobalMemoryStatusEx (&statex); - if (statex.ullAvailPhys > (long long int)10*1024*1024*1024) { + if (statex.ullAvailPhys > (long long int)16*1024*1024*1024) { doClear = false; } -#endif - - mClearWhenEditorHidden = boolValue("clear_when_editor_hidden",doClear); - - bool shouldShare=true; - -#ifdef Q_OS_WIN - statex.dwLength = sizeof (statex); - - GlobalMemoryStatusEx (&statex); - if (statex.ullAvailPhys > (long long int)8*1024*1024*1024) { + if (statex.ullAvailPhys > (long long int)10*1024*1024*1024) { shouldShare = false; } #endif + mClearWhenEditorHidden = boolValue("clear_when_editor_hidden",doClear); mShareParser = boolValue("share_parser",shouldShare); } diff --git a/libs/redpanda_qt_utils/qt_utils/utils.cpp b/libs/redpanda_qt_utils/qt_utils/utils.cpp index af562e93..afa248a5 100644 --- a/libs/redpanda_qt_utils/qt_utils/utils.cpp +++ b/libs/redpanda_qt_utils/qt_utils/utils.cpp @@ -452,7 +452,7 @@ bool copyFile(const QString &fromPath, const QString &toPath, bool overwrite) if (!toFile.open(QFile::WriteOnly | QFile::Truncate)) return false; - int bufferSize=64*1024; + constexpr int bufferSize=64*1024; char buffer[bufferSize]; while (!fromFile.atEnd()) { diff --git a/tools/redpanda-win-git-askpass/redpanda-win-git-askpass.pro b/tools/redpanda-win-git-askpass/redpanda-win-git-askpass.pro index f2bfddc3..93f1b055 100644 --- a/tools/redpanda-win-git-askpass/redpanda-win-git-askpass.pro +++ b/tools/redpanda-win-git-askpass/redpanda-win-git-askpass.pro @@ -1,13 +1,5 @@ -#win32-msvc{ -# CONFIG += c++11 -# CONFIG -= app_bundle -#} else { -# TEMPLATE = app - -# CONFIG += windows -# CONFIG -= app_bundle -# CONFIG -= qt -#} +CONFIG += windows +CONFIG -= qt CONFIG += c++11 CONFIG -= app_bundle