Skip to content

Commit

Permalink
Backport: Fix core dump issue (#44)
Browse files Browse the repository at this point in the history
* Backport from new fixes

* Bump to 2.1.5+backport1

* Update artifact
  • Loading branch information
elysia-best authored Nov 13, 2024
1 parent 5aa0298 commit c96c59f
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 80 deletions.
40 changes: 13 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
lingmo-settings (2.1.5+backport1) main; urgency=high

[Elysia]
* Fix core dump issue

-- Lingm OS Team <[email protected]> Wed, 13 Nov 2024 15:45:05 +0000

lingmo-settings (2.1.5-rc1) main; urgency=high

[Lingmo OS Team]
Expand Down
37 changes: 3 additions & 34 deletions src/application.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "application.h"

#include <QCommandLineParser>
#include <QDBusConnection>
#include <QDBusPendingCall>
#include <QGuiApplication>
Expand Down Expand Up @@ -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<QQmlApplicationEngine> engine) : m_engine(engine) {

new SettingsUIAdaptor(this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/SettingsUI"),
Expand Down Expand Up @@ -106,8 +85,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) {
qmlRegisterAnonymousType<QAbstractItemModel>(uri, 1);
#endif

QGuiApplication app(argc, argv);

// Translations
QLocale locale;
QString qmFilePath = QString("%1/%2.qm")
Expand All @@ -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() {
Expand Down
9 changes: 6 additions & 3 deletions src/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
#include <QDBusConnection>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <memory>
#include <qguiapplication.h>
#include <qobject.h>

#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<QQmlApplicationEngine> 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<QQmlApplicationEngine> m_engine;
};

#endif // APPLICATION_H
59 changes: 43 additions & 16 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <QCommandLineParser>
#include <QDBusConnection>
#include <QDebug>
#include <QFile>
Expand All @@ -26,27 +27,53 @@
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QTranslator>
#include <QDBusInterface>
#include <qguiapplication.h>

#include <memory>
#include <qqmlapplicationengine.h>

#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<QQmlApplicationEngine>();

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();
}

0 comments on commit c96c59f

Please sign in to comment.