From 7e2c5612cba57df7d100586c4dcb6288cebc8c5d Mon Sep 17 00:00:00 2001 From: rong wang Date: Tue, 18 Mar 2025 14:36:09 +0800 Subject: [PATCH] fix: Fix get device info fail when init When deepin-diskmanager starts, it will start deepin-diskmanager-service first, and then obtain device information from deepin-diskmanager-service. If deepin-diskmanager-service takes too long to initialize due to the existence of external storage devices, deepin-diskmanager will fail to obtain device information. At this time, deepin-diskmanager-service has not registered the dbus service. Let's re-initiate the request after failing to obtain device information. Log: Fix get device info fail when init Bug: https://pms.uniontech.com/bug-view-308533.html --- application/partedproxy/dmdbushandler.cpp | 19 ++++++++++++++++++- application/partedproxy/dmdbushandler.h | 5 +++++ application/partedproxy/dmdbusinterface.h | 2 +- debian/changelog | 7 +++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/application/partedproxy/dmdbushandler.cpp b/application/partedproxy/dmdbushandler.cpp index 01d107f2..f483b953 100644 --- a/application/partedproxy/dmdbushandler.cpp +++ b/application/partedproxy/dmdbushandler.cpp @@ -203,11 +203,28 @@ QString DMDbusHandler::getRootLoginResult() return m_loginMessage; } +void DMDbusHandler::getAllDevice() +{ + QDBusPendingCall pendingCall = m_dbus->getalldevice(); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall); + + // 连接完成信号 + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, + [=](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<> reply = *watcher; + if (reply.isError()) { + qDebug() << __FUNCTION__ << reply.error().message(); + QTimer::singleShot(500, this, SLOT(getAllDevice())); + } + watcher->deleteLater(); + }); +} + void DMDbusHandler::getDeviceInfo() { emit showSpinerWindow(true, tr("Initializing data...")); - m_dbus->getalldevice(); + getAllDevice(); qDebug() << __FUNCTION__ << "-------"; } diff --git a/application/partedproxy/dmdbushandler.h b/application/partedproxy/dmdbushandler.h index 1ff29e2b..a1dd1f3e 100644 --- a/application/partedproxy/dmdbushandler.h +++ b/application/partedproxy/dmdbushandler.h @@ -527,6 +527,11 @@ private slots: */ void onUpdateUsb(); + /** + * @brief 触发重新请求设备信息的槽函数 + */ + void getAllDevice(); + private: DMDBusInterface *m_dbus = nullptr; static DMDbusHandler *m_staticHandeler; diff --git a/application/partedproxy/dmdbusinterface.h b/application/partedproxy/dmdbusinterface.h index 704af1d6..8c771dbb 100644 --- a/application/partedproxy/dmdbusinterface.h +++ b/application/partedproxy/dmdbusinterface.h @@ -94,7 +94,7 @@ public Q_SLOTS: // METHODS /** * @brief 获取所有设备 */ - inline QDBusPendingReply<> getalldevice() + inline QDBusPendingCall getalldevice() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("getalldevice"), argumentList); diff --git a/debian/changelog b/debian/changelog index 5f979aad..83a3da9c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +deepin-diskmanager (6.0.2) unstable; urgency=medium + + * new tag v6.0.2 + * fix get device info fail when init. + + -- wangrong Tue, 18 Mar 2025 14:21:23 +0800 + deepin-diskmanager (6.0.1) unstable; urgency=medium * new tag v6.0.1