fix: core dumped under Qt 6.4
1. call method metaObject of QMetaType will coredump under Qt 6.4 2. remove `std::terminate()` when AM can't connect to Systemd Signals. 3. call `Subscribe` before connecting to Systemd Signals to guarantee that systemd will send UnitNew and UnitRemoved. Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
ce2148e5cd
commit
6fae5a758b
@ -26,6 +26,7 @@ void registerComplexDbusType()
|
|||||||
qDBusRegisterMetaType<QMap<QString, QString>>();
|
qDBusRegisterMetaType<QMap<QString, QString>>();
|
||||||
qRegisterMetaType<PropMap>();
|
qRegisterMetaType<PropMap>();
|
||||||
qDBusRegisterMetaType<PropMap>();
|
qDBusRegisterMetaType<PropMap>();
|
||||||
|
qDBusRegisterMetaType<QDBusObjectPath>();
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -35,4 +35,11 @@ constexpr auto ApplicationManagerDestDBusName =
|
|||||||
u8"deepin_application_manager_dest_bus";
|
u8"deepin_application_manager_dest_bus";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
constexpr auto ObjectManagerInterface = "org.desktopspec.DBus.ObjectManager";
|
||||||
|
constexpr auto JobManagerInterface = "org.desktopspec.JobManager1";
|
||||||
|
constexpr auto JobInterface = "org.desktopspec.JobManager1.Job";
|
||||||
|
constexpr auto ApplicationManagerInterface = "org.desktopspec.ApplicationManager1";
|
||||||
|
constexpr auto InstanceInterface = "org.desktopspec.ApplicationManager1.Instance";
|
||||||
|
constexpr auto ApplicationInterface = "org.desktopspec.ApplicationManager1.Application";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,8 +28,7 @@ ApplicationManager1Service::ApplicationManager1Service(std::unique_ptr<Identifie
|
|||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!registerObjectToDBus(
|
if (!registerObjectToDBus(this, DDEApplicationManager1ObjectPath, ApplicationManagerInterface)) {
|
||||||
this, DDEApplicationManager1ObjectPath, getDBusInterface(QMetaType::fromType<ApplicationManager1Adaptor>()))) {
|
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,8 +129,7 @@ bool ApplicationManager1Service::addApplication(DesktopFile desktopFileSource) n
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!registerObjectToDBus(
|
if (!registerObjectToDBus(ptr, application->applicationPath().path(), ApplicationInterface)) {
|
||||||
ptr, application->applicationPath().path(), getDBusInterface(QMetaType::fromType<ApplicationAdaptor>()))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_applicationList.insert(application->applicationPath(), application);
|
m_applicationList.insert(application->applicationPath(), application);
|
||||||
|
@ -317,7 +317,7 @@ bool ApplicationService::addOneInstance(const QString &instanceId, const QString
|
|||||||
auto *adaptor = new InstanceAdaptor(service);
|
auto *adaptor = new InstanceAdaptor(service);
|
||||||
QString objectPath{m_applicationPath.path() + "/" + instanceId};
|
QString objectPath{m_applicationPath.path() + "/" + instanceId};
|
||||||
|
|
||||||
if (registerObjectToDBus(service, objectPath, getDBusInterface(QMetaType::fromType<InstanceAdaptor>()))) {
|
if (registerObjectToDBus(service, objectPath, InstanceInterface)) {
|
||||||
m_Instances.insert(QDBusObjectPath{objectPath}, QSharedPointer<InstanceService>{service});
|
m_Instances.insert(QDBusObjectPath{objectPath}, QSharedPointer<InstanceService>{service});
|
||||||
service->moveToThread(this->thread());
|
service->moveToThread(this->thread());
|
||||||
adaptor->moveToThread(this->thread());
|
adaptor->moveToThread(this->thread());
|
||||||
|
@ -9,8 +9,7 @@ JobManager1Service::JobManager1Service(ApplicationManager1Service *parent)
|
|||||||
: m_parent(parent)
|
: m_parent(parent)
|
||||||
{
|
{
|
||||||
new JobManager1Adaptor{this};
|
new JobManager1Adaptor{this};
|
||||||
if (!registerObjectToDBus(
|
if (!registerObjectToDBus(this, DDEApplicationManager1JobManagerObjectPath, JobManagerInterface)) {
|
||||||
this, DDEApplicationManager1JobManagerObjectPath, getDBusInterface(QMetaType::fromType<JobManager1Adaptor>()))) {
|
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
qRegisterMetaType<LaunchTask>();
|
qRegisterMetaType<LaunchTask>();
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
|
|
||||||
auto *ptr = job.data();
|
auto *ptr = job.data();
|
||||||
new JobAdaptor(ptr);
|
new JobAdaptor(ptr);
|
||||||
if (!registerObjectToDBus(ptr, objectPath, getDBusInterface(QMetaType::fromType<JobAdaptor>()))) {
|
if (!registerObjectToDBus(ptr, objectPath, JobInterface)) {
|
||||||
qCritical() << "can't register job to dbus.";
|
qCritical() << "can't register job to dbus.";
|
||||||
future.cancel();
|
future.cancel();
|
||||||
return {};
|
return {};
|
||||||
|
22
src/global.h
22
src/global.h
@ -196,12 +196,24 @@ void unregisterObjectFromDBus(const QString &path);
|
|||||||
|
|
||||||
inline QString getDBusInterface(const QMetaType &meta)
|
inline QString getDBusInterface(const QMetaType &meta)
|
||||||
{
|
{
|
||||||
const auto *infoObject = meta.metaObject();
|
auto name = QString{meta.name()};
|
||||||
if (auto infoIndex = infoObject->indexOfClassInfo("D-Bus Interface"); infoIndex != -1) {
|
if (name == "ApplicationAdaptor") {
|
||||||
return infoObject->classInfo(infoIndex).value();
|
return ApplicationInterface;
|
||||||
}
|
}
|
||||||
qWarning() << "no interface found.";
|
|
||||||
return {};
|
if (name == "InstanceAdaptor") {
|
||||||
|
return InstanceInterface;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == "APPObjectManagerAdaptor" or name == "AMObjectManagerAdaptor") {
|
||||||
|
return ObjectManagerInterface;
|
||||||
|
}
|
||||||
|
// const auto *infoObject = meta.metaObject();
|
||||||
|
// if (auto infoIndex = infoObject->indexOfClassInfo("D-Bus Interface"); infoIndex != -1) {
|
||||||
|
// return infoObject->classInfo(infoIndex).value();
|
||||||
|
// }
|
||||||
|
qWarning() << "couldn't found interface:" << name;
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ObjectInterfaceMap getChildInterfacesAndPropertiesFromObject(QObject *o)
|
inline ObjectInterfaceMap getChildInterfacesAndPropertiesFromObject(QObject *o)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define SYSTEMDSIGNALDISPATCHER_H
|
#define SYSTEMDSIGNALDISPATCHER_H
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include <QDBusMessage>
|
||||||
|
|
||||||
class SystemdSignalDispatcher : public QObject
|
class SystemdSignalDispatcher : public QObject
|
||||||
{
|
{
|
||||||
@ -29,8 +30,13 @@ private:
|
|||||||
explicit SystemdSignalDispatcher(QObject *parent = nullptr)
|
explicit SystemdSignalDispatcher(QObject *parent = nullptr)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
auto &con = ApplicationManager1DBus::instance().globalDestBus();
|
||||||
|
auto ret = con.call(QDBusMessage::createMethodCall(SystemdService, SystemdObjectPath, SystemdInterfaceName, "Subscribe"));
|
||||||
|
if (ret.type() == QDBusMessage::ErrorMessage) {
|
||||||
|
qFatal("%s", ret.errorMessage().toLocal8Bit().data());
|
||||||
|
}
|
||||||
if (!connectToSignals()) {
|
if (!connectToSignals()) {
|
||||||
std::terminate();
|
qCritical() << "couldn't connect to Systemd signals";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool connectToSignals() noexcept;
|
bool connectToSignals() noexcept;
|
||||||
|
Loading…
Reference in New Issue
Block a user