From c96c59fcd581cfa62203cbc12a44ab8b1c8f63d8 Mon Sep 17 00:00:00 2001 From: Yinan Qin Date: Wed, 13 Nov 2024 23:51:21 +0800 Subject: [PATCH] Backport: Fix core dump issue (#44) * Backport from new fixes * Bump to 2.1.5+backport1 * Update artifact --- .github/workflows/build.yml | 40 ++++++++----------------- debian/changelog | 7 +++++ src/application.cpp | 37 ++--------------------- src/application.h | 9 ++++-- src/main.cpp | 59 +++++++++++++++++++++++++++---------- 5 files changed, 72 insertions(+), 80 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9131f78..11ce676 100755 --- 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 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 + mkdir -p artifacts + cp -rfv ../*.deb ./artifacts + + - uses: actions/upload-artifact@v4 + with: + name: Lingmo Artifacts + path: artifacts + compression-level: 9 # maximum compression diff --git a/debian/changelog b/debian/changelog index 7d57404..8f82825 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +lingmo-settings (2.1.5+backport1) main; urgency=high + + [Elysia] + * Fix core dump issue + + -- Lingm OS Team Wed, 13 Nov 2024 15:45:05 +0000 + lingmo-settings (2.1.5-rc1) main; urgency=high [Lingmo OS Team] diff --git a/src/application.cpp b/src/application.cpp index 1d8f767..5e3f74d 100755 --- a/src/application.cpp +++ b/src/application.cpp @@ -1,6 +1,5 @@ #include "application.h" -#include #include #include #include @@ -45,27 +44,7 @@ static QObject *passwordSingleton(QQmlEngine *engine, QJSEngine *scriptEngine) { 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; - } +Application::Application(std::shared_ptr engine) : m_engine(engine) { new SettingsUIAdaptor(this); QDBusConnection::sessionBus().registerObject(QStringLiteral("/SettingsUI"), @@ -106,8 +85,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) { qmlRegisterAnonymousType(uri, 1); #endif - QGuiApplication app(argc, argv); - // Translations QLocale locale; QString qmFilePath = QString("%1/%2.qm") @@ -122,18 +99,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) { } } - m_engine.addImportPath(QStringLiteral("qrc:/")); - m_engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); - - // m_engine.rootContext()->setContextProperty("upgradeableModel", UpgradeableModel::self()); - - if (!module.isEmpty()) { - switchToPage(module); - } - insertPlugin(); - QApplication::exec(); + m_engine->addImportPath(QStringLiteral("qrc:/")); + m_engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); } void Application::insertPlugin() { diff --git a/src/application.h b/src/application.h index 14d792d..28428eb 100755 --- a/src/application.h +++ b/src/application.h @@ -5,21 +5,24 @@ #include #include #include +#include +#include +#include #include "include/interface/moduleinterface.h" -class Application : public QApplication { +class Application : public QObject { Q_OBJECT public: - explicit Application(int &argc, char **argv); + explicit Application(std::shared_ptr engine); void addPage(QString title, QString name, QString page, QString iconSource, QString iconColor, QString category); void switchToPage(const QString &name); private: void insertPlugin(); - QQmlApplicationEngine m_engine; + std::shared_ptr m_engine; }; #endif // APPLICATION_H diff --git a/src/main.cpp b/src/main.cpp index a23d093..037fffa 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -26,27 +27,53 @@ #include #include #include +#include +#include + +#include +#include #include "application.h" -int main(int argc, char *argv[]) { - QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); - QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, true); +int main(int argc, char* argv[]) +{ + + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); + QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, true); + + QGuiApplication app(argc, argv); + + app.setWindowIcon(QIcon::fromTheme("lingmo-settings")); + app.setOrganizationName("Lingmo Community"); + + QCommandLineParser parser; + parser.setApplicationDescription(QStringLiteral("Lingmo Settings")); + parser.addHelpOption(); + + QCommandLineOption moduleOption("m", "Switch to module", "module"); + parser.addOption(moduleOption); + parser.process(app); + + 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 0; + } - Application app(argc, argv); + auto engine = std::make_shared(); - app.setWindowIcon(QIcon::fromTheme("lingmo-settings")); + Application My_App(engine); - // QQmlApplicationEngine engine; - // const QUrl url(QStringLiteral("qrc:/main.qml")); - // QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, - // &app, [url](QObject *obj, const QUrl &objUrl) { - // if (!obj && url == objUrl) - // QCoreApplication::exit(-1); - // }, Qt::QueuedConnection); - // engine.rootContext()->setContextProperty("upgradeableModel", - // UpgradeableModel::self()); engine.load(url); + if (!module.isEmpty()) { + My_App.switchToPage(module); + } - return 0; + return QGuiApplication::exec(); }