From 197eeec69a799b1770fe6b5d15ecf9ee34e7fea6 Mon Sep 17 00:00:00 2001 From: Yinan Qin Date: Sat, 26 Oct 2024 19:53:05 +0800 Subject: [PATCH] Fixed Core Dump issue (#40) * Fixed Core Dump issue - Fixed https://github.com/LingmoOS/lingmo-settings/issues/24 - Bumped versin to 3.0.0~rc3 * Fix icon name * Fix CI * Added build deps --- .clang-format | 225 ++++++++++++++++++++++++++++++ .github/workflows/build.yml | 40 ++---- CMakeLists.txt | 4 + debian/changelog | 7 + debian/control | 1 + src/application.cpp | 269 +++++++++++++++++------------------- src/application.h | 28 ++-- src/main.cpp | 60 +++++--- src/qml/main.qml | 5 +- translations/ar_AA.ts | 2 +- translations/az_AZ.ts | 2 +- translations/be_BY.ts | 2 +- translations/be_Latn.ts | 2 +- translations/bg_BG.ts | 2 +- translations/bs_BA.ts | 2 +- translations/cs_CZ.ts | 2 +- translations/da_DK.ts | 2 +- translations/de_DE.ts | 2 +- translations/en_US.ts | 2 +- translations/eo_XX.ts | 2 +- translations/es_ES.ts | 2 +- translations/es_MX.ts | 2 +- translations/fa_IR.ts | 2 +- translations/fi_FI.ts | 2 +- translations/fr_FR.ts | 2 +- translations/he_IL.ts | 2 +- translations/hi_IN.ts | 2 +- translations/hu_HU.ts | 2 +- translations/id_ID.ts | 2 +- translations/ie.ts | 2 +- translations/it_IT.ts | 2 +- translations/ja_JP.ts | 2 +- translations/lt_LT.ts | 2 +- translations/lv_LV.ts | 2 +- translations/mg.ts | 2 +- translations/ml_IN.ts | 2 +- translations/nb_NO.ts | 2 +- translations/ne_NP.ts | 2 +- translations/pl_PL.ts | 2 +- translations/pt_BR.ts | 2 +- translations/pt_PT.ts | 2 +- translations/ro_RO.ts | 2 +- translations/ru_RU.ts | 2 +- translations/si_LK.ts | 2 +- translations/sk_SK.ts | 2 +- translations/so.ts | 2 +- translations/sr_RS.ts | 2 +- translations/sv_SE.ts | 2 +- translations/sw.ts | 2 +- translations/ta_IN.ts | 2 +- translations/tr_TR.ts | 2 +- translations/uk_UA.ts | 2 +- translations/uz_UZ.ts | 2 +- translations/vi_VN.ts | 2 +- translations/zh_CN.ts | 2 +- translations/zh_HK.ts | 2 +- translations/zh_TW.ts | 2 +- 57 files changed, 492 insertions(+), 243 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..8eda42f --- /dev/null +++ b/.clang-format @@ -0,0 +1,225 @@ +--- +Language: Cpp +# BasedOnStyle: WebKit +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignEscapedNewlines: Right +AlignOperands: DontAlign +AlignTrailingComments: + Kind: Never + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAfterAttributes: Never +BreakAfterJavaFieldAnnotations: false +BreakArrays: true +BreakBeforeBinaryOperators: All +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: WebKit +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: false +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 4 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseTab: Never +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +... + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9131f78..c2adcd3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,40 +17,26 @@ jobs: container: docker.io/library/debian:trixie steps: - name: Checkout Source - uses: actions/checkout@v2 + uses: actions/checkout@v4 + + - name: Update Lingmo repo + run: | + apt-get update -y && apt-get upgrade -y && apt-get install -y apt-transport-https ca-certificates + echo "deb [trusted=yes] https://raw.githubusercontent.com/LingmoOS/lingmo-nightly-build/refs/heads/main nightly experimental" >> /etc/apt/sources.list.d/lingmo-rolling.list + apt-get update + - name: Update repository run: apt-get update -y + - name: Install the basic dev packages run: apt-get install -y equivs curl git devscripts lintian build-essential automake autotools-dev cmake g++ + - name: Install build dependencies run: mk-build-deps -i -t "apt-get --yes" -r - - name: Fix KF5 - run: mkdir -p /usr/include/KF5 + + - name: Build Package run: | chmod -x debian/lingmo-* dpkg-buildpackage -b -uc -us -j$(nproc) - # - name: Create Release - # id: create_release - # uses: actions/create-release@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # tag_name: 2.0 - # release_name: Release 2.0.0 Packages - # draft: false - # prerelease: false - # - name: Upload Release Asset - # id: upload-release-asset - # uses: actions/upload-release-asset@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # upload_url: ${{ steps.create_release.outputs.upload_url }} - # asset_path: | - # /__w/lingmo-settings/lingmo-settings_2.0.0-3_amd64.deb - # /__w/lingmo-settings/lingmo-settings-dev_2.0.0-3_amd64.deb - # asset_name: | - # lingmo-settings_2.0.0-3_amd64.deb - # lingmo-settings-dev_2.0.0-3_amd64.deb - # asset_content_type: application/deb + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 90ae1f6..2921dd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,8 @@ find_package(KF5NetworkManagerQt REQUIRED) find_package(KF5ModemManagerQt REQUIRED) find_package(KF5Config) +find_package(LingmoLogger REQUIRED) + pkg_search_module(FontConfig REQUIRED fontconfig IMPORTED_TARGET) pkg_search_module(ICU REQUIRED icu-i18n) @@ -78,6 +80,8 @@ target_link_libraries(${PROJECT_NAME} X11::X11 X11::Xi X11::Xcursor + + LingmoLogger ) file(GLOB TS_FILES translations/*.ts) diff --git a/debian/changelog b/debian/changelog index adcbb4e..c12429b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +lingmo-settings (3.0.0~rc3) UNRELEASED; urgency=high + + [Elysia] + * Fix a critical core dump when existing app. See https://github.com/LingmoOS/lingmo-settings/issues/24 + + -- Lingmo OS Team Fri, 18 Oct 2024 19:26:23 +0800 + lingmo-settings (3.0.0~rc2) UNRELEASED; urgency=low [Elysia] diff --git a/debian/control b/debian/control index 3877ebd..4658d9a 100644 --- a/debian/control +++ b/debian/control @@ -5,6 +5,7 @@ Maintainer: LingmoOS Build-Depends: cmake, debhelper (>= 9), extra-cmake-modules, + liblingmo, libicu-dev, libcrypt-dev, libx11-dev, diff --git a/src/application.cpp b/src/application.cpp index 8638893..00ae46f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -1,6 +1,7 @@ +#define LOG_TAG "Settings::Application" + #include "application.h" -#include #include #include #include @@ -11,6 +12,8 @@ #include // #include +#include + #include "about.h" // #include "hostname.h" #include "accessibility.h" @@ -38,164 +41,150 @@ const QString ModuleDirectory = "/usr/lib/lingmo-settings/modules"; -static QObject *passwordSingleton(QQmlEngine *engine, QJSEngine *scriptEngine) { - Q_UNUSED(engine); - Q_UNUSED(scriptEngine); +static QObject* passwordSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); - Password *object = new Password(); - return object; + Password* object = new Password(); + return object; } -Application::Application(int &argc, char **argv) : QApplication(argc, argv) { - setWindowIcon(QIcon::fromTheme("preferences-system")); - setOrganizationName("lingmoos"); - - QCommandLineParser parser; - parser.setApplicationDescription(QStringLiteral("Lingmo Settings")); - parser.addHelpOption(); - - QCommandLineOption moduleOption("m", "Switch to module", "module"); - parser.addOption(moduleOption); - parser.process(*this); - - const QString module = parser.value(moduleOption); - - if (!QDBusConnection::sessionBus().registerService("com.lingmo.SettingsUI")) { - QDBusInterface iface("com.lingmo.SettingsUI", "/SettingsUI", - "com.lingmo.SettingsUI", - QDBusConnection::sessionBus()); - if (iface.isValid()) iface.call("switchToPage", module); - return; - } - - new SettingsUIAdaptor(this); - QDBusConnection::sessionBus().registerObject(QStringLiteral("/SettingsUI"), - this); - // QML - const char *uri = "Lingmo.Settings"; - // @uri Lingmo.Settings - qmlRegisterType(uri, 1, 0, "Appearance"); - qmlRegisterType(uri, 1, 0, "FontsModel"); - qmlRegisterType(uri, 1, 0, "Brightness"); - qmlRegisterType(uri, 1, 0, "Battery"); - qmlRegisterType(uri, 1, 0, "BatteryHistoryModel"); - qmlRegisterType(uri, 1, 0, "CursorThemeModel"); - qmlRegisterType(uri, 1, 0, "About"); - qmlRegisterType(uri, 1, 0, "Background"); - qmlRegisterType(uri, 1, 0, "Language"); - qmlRegisterType(uri, 1, 0, "Fonts"); -// qmlRegisterType(uri, 1, 0, "HostNameChanger"); - qmlRegisterType(uri, 1, 0, "PowerManager"); - qmlRegisterType(uri, 1, 0, "Mouse"); - qmlRegisterType