forked from linuxdeepin/deepin-system-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 多次双击插件弹框种的模块插件卡死,应用关闭双击插件模块未跳转到对应详情页
【龙芯】【常用工具2021H2系统监视器】【5.9.0.5】应用关闭双击插件模块未跳转到对应详情页 多次双击插件弹框种的模块插件卡死 Log: 【龙芯】【常用工具2021H2系统监视器】【5.9.0.5】应用关闭双击插件模块未跳转到对应详情页 多次双击插件弹框种的模块插件卡死 Change-Id: I62136370d6d89daf22c704b0d8b3ff286efb5393
- Loading branch information
Showing
27 changed files
with
257 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ build/ | |
*.user.* | ||
.vscode/* | ||
.directory | ||
config.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. | ||
* | ||
* Author: yukuan<[email protected]> | ||
* Maintainer: yukuan<[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "dbus_object.h" | ||
#include "gui/main_window.h" | ||
#include "application.h" | ||
|
||
#include <QDBusConnection> | ||
#include <QDebug> | ||
|
||
#define DBUS_SERVER "com.deepin.systemMonitor" | ||
#define DBUS_SERVER_PATH "/com/deepin/systemMonitor" | ||
|
||
QMutex DBusObject::mutex; | ||
QAtomicPointer<DBusObject> DBusObject::instance; | ||
|
||
DBusObject &DBusObject::getInstance() | ||
{ | ||
if (instance.testAndSetOrdered(nullptr, nullptr)) | ||
{ | ||
QMutexLocker locker(&mutex); | ||
|
||
instance.testAndSetOrdered(nullptr, new DBusObject); | ||
} | ||
return *instance; | ||
} | ||
|
||
bool DBusObject::registerOrNotify() | ||
{ | ||
QDBusConnection dbus = QDBusConnection::sessionBus(); | ||
if (!dbus.registerService(DBUS_SERVER)) { | ||
QDBusInterface notification(DBUS_SERVER, DBUS_SERVER_PATH, DBUS_SERVER, QDBusConnection::sessionBus()); | ||
QList<QVariant> args; | ||
QString error = notification.callWithArgumentList(QDBus::Block, "handleWindow", args).errorMessage(); | ||
if (!error.isEmpty()) | ||
qInfo() << error; | ||
return false; | ||
} | ||
|
||
dbus.registerObject(DBUS_SERVER_PATH, this, QDBusConnection::ExportScriptableSlots); | ||
|
||
return true; | ||
} | ||
|
||
void DBusObject::unRegister() | ||
{ | ||
internalMutex.lockForRead(); | ||
QDBusConnection dbus = QDBusConnection::sessionBus(); | ||
dbus.unregisterService(DBUS_SERVER); | ||
internalMutex.unlock(); | ||
} | ||
|
||
void DBusObject::handleWindow() | ||
{ | ||
internalMutex.lockForRead(); | ||
MainWindow *mw = gApp->mainWindow(); | ||
mw->setWindowState((mw->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); | ||
internalMutex.unlock(); | ||
} | ||
|
||
DBusObject::DBusObject(QObject *parent) : QObject(parent) | ||
{ | ||
|
||
} | ||
|
||
DBusObject::~DBusObject() | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. | ||
* | ||
* Author: yukuan<[email protected]> | ||
* Maintainer: yukuan<[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef DBUS_OBJECT_H | ||
#define DBUS_OBJECT_H | ||
|
||
|
||
#include <QObject> | ||
#include <QDBusInterface> | ||
#include <QDBusReply> | ||
#include <QDBusUnixFileDescriptor> | ||
#include <QMutex> | ||
#include <QReadWriteLock> | ||
|
||
class DBusObject : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_CLASSINFO("D-Bus Interface", "com.deepin.systemMonitor") | ||
public: | ||
static DBusObject &getInstance(); | ||
|
||
/** | ||
* @brief registerOrNotify | ||
* 注册服务,成功返回true,如果失败则通知已经存在的服务并返回false | ||
* @return | ||
*/ | ||
bool registerOrNotify(); | ||
|
||
/** | ||
* @brief unRegister | ||
* 反注册,当应用准备销毁时调用 | ||
*/ | ||
void unRegister(); | ||
|
||
|
||
public slots: | ||
/** | ||
* @brief handleWindow | ||
* 接收DBus激活窗口响应接口 | ||
*/ | ||
Q_SCRIPTABLE void handleWindow(); | ||
|
||
private: | ||
DBusObject(QObject *parent = nullptr); | ||
~DBusObject(); | ||
DBusObject(const DBusObject &) = delete; | ||
DBusObject &operator=(const DBusObject &) = delete; | ||
|
||
private: | ||
QReadWriteLock internalMutex; | ||
static QMutex mutex; | ||
static QAtomicPointer<DBusObject> instance; | ||
}; | ||
|
||
#endif // DBUS_OBJECT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.