Skip to content

Commit

Permalink
fix: 多次双击插件弹框种的模块插件卡死,应用关闭双击插件模块未跳转到对应详情页
Browse files Browse the repository at this point in the history
【龙芯】【常用工具2021H2系统监视器】【5.9.0.5】应用关闭双击插件模块未跳转到对应详情页 多次双击插件弹框种的模块插件卡死

Log: 【龙芯】【常用工具2021H2系统监视器】【5.9.0.5】应用关闭双击插件模块未跳转到对应详情页 多次双击插件弹框种的模块插件卡死
Change-Id: I62136370d6d89daf22c704b0d8b3ff286efb5393
  • Loading branch information
allen5864 committed Oct 28, 2021
1 parent fa9eef9 commit f90a103
Show file tree
Hide file tree
Showing 27 changed files with 257 additions and 78 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build/
*.user.*
.vscode/*
.directory
config.h
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ if (${XDGTYPE} MATCHES "wayland")
else()
SET(WAYLAND_SESSION_TYPE 0)
endif()

#判断龙芯架构
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips64")
SET(IS_LOONGARCH_TYPE 1)
elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "__longarch64")
SET(NOT_LOONGARCH_TYPE )
else()
SET(IS_LOONGARCH_TYPE 0)
endif()

#系统监视器主应用
ADD_SUBDIRECTORY(deepin-system-monitor-main)
#系统监视器插件
Expand All @@ -44,3 +54,4 @@ ADD_SUBDIRECTORY(deepin-system-monitor-daemon)
#单元测试
ADD_SUBDIRECTORY(tests)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
1 change: 1 addition & 0 deletions deepin-system-monitor-main/config.h.in → config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
#cmakedefine HAVE_SYS_CALL 1
#cmakedefine HAVE_SYS_GETRANDOM 1
#cmakedefine WAYLAND_SESSION_TYPE
#cmakedefine IS_LOONGARCH_TYPE
7 changes: 4 additions & 3 deletions deepin-system-monitor-main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ check_include_files ("sys/random.h" HAVE_SYS_RANDOM_H)
include(CheckSymbolExists)
check_symbol_exists(syscall "unistd.h" HAVE_SYS_CALL)
check_symbol_exists(SYS_getrandom "sys/syscall.h" HAVE_SYS_GETRANDOM)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include(FindPkgConfig)

find_package(KF5Wayland)
Expand Down Expand Up @@ -62,10 +61,9 @@ include_directories(${LIB_UDEV_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libsmartcols/src)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)

set(HPP_GLOBAL
config.h
environments.h
accessible.h
accessibledefine.h
Expand Down Expand Up @@ -128,6 +126,7 @@ set(HPP_DBUS
dbus/unit_file_info.h
dbus/unit_info.h
dbus/dbusforsystemomonitorpluginservce.h
dbus/dbus_object.h
)
set(CPP_DBUS
dbus/environment_file.cpp
Expand All @@ -138,6 +137,7 @@ set(CPP_DBUS
dbus/systemd1_unit_interface.cpp
dbus/dbus_properties_interface.cpp
dbus/dbusforsystemomonitorpluginservce.cpp
dbus/dbus_object.cpp
)

set(HPP_MODEL
Expand Down Expand Up @@ -492,6 +492,7 @@ set(LSCPU_INCLUDE
)

set(APP_HPP
${CMAKE_HOME_DIRECTORY}/config.h
${HPP_GLOBAL}
${HPP_COMMON}
${HPP_DBUS}
Expand Down
6 changes: 2 additions & 4 deletions deepin-system-monitor-main/common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,9 @@ QString format::formatUnit(QVariant size, format::SizeUnit base, int prec, bool

if (isSpeed) {
return QString("%1 %2%3").arg(v, 0, 'f', prec).arg(UnitSuffixExt[u]).arg("/s");
} else {
//return QString("%1 %2").arg(v, 0, 'f', prec).arg(UnitSuffix[u]);
//统一单位
return QString("%1 %2").arg(v, 0, 'f', prec).arg(UnitSuffixExt[u]);
}
//统一单位
return QString("%1 %2").arg(v, 0, 'f', prec).arg(UnitSuffixExt[u]);
}

// ::format::formatUnit
Expand Down
85 changes: 85 additions & 0 deletions deepin-system-monitor-main/dbus/dbus_object.cpp
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()
{

}
71 changes: 71 additions & 0 deletions deepin-system-monitor-main/dbus/dbus_object.h
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
4 changes: 2 additions & 2 deletions deepin-system-monitor-main/gui/base/base_detail_view_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public slots:
// 切换多核显示或单CPU显示 按钮
Dtk::Widget::DIconButton *m_switchButton;
// 切换按钮图片
QIcon *m_switchIconLight;
QIcon *m_switchIconDark;
QIcon *m_switchIconLight {};
QIcon *m_switchIconDark {};

// 当前是否为多核模式
bool m_isMultiCoreMode = false;
Expand Down
8 changes: 2 additions & 6 deletions deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ void XWinKillPreviewWidget::mousePressEvent(QMouseEvent *event)
it!=m_windowStates.end();++it) {
// if the window is created by ourself, then ignore it
qDebug()<<it->pid;
if (getpid() == it->pid || QString::fromStdString(it->resourceName)=="dde-desktop" ||
QString::fromStdString(it->resourceName) == "deepin-system-monitor"||
QString::fromStdString(it->resourceName)=="qtcreator")
if (getpid() == it->pid || QString::fromStdString(it->resourceName)=="dde-desktop")
continue;

// if such window exists, we emit window clicked signal to notify kill application performed action
Expand Down Expand Up @@ -173,9 +171,7 @@ void XWinKillPreviewWidget::mouseMoveEvent(QMouseEvent *)
for (QVector<ClientManagement::WindowState>::iterator it=m_windowStates.begin();
it!=m_windowStates.end();++it) {
// if the window is created by ourself, then ignore it
if (getpid() == it->pid|| QString::fromStdString(it->resourceName)=="dde-desktop" ||
QString::fromStdString(it->resourceName) == "deepin-system-monitor"||
QString::fromStdString(it->resourceName)=="qtcreator")
if (getpid() == it->pid|| QString::fromStdString(it->resourceName)=="dde-desktop")
continue;
auto selRect = QRect(static_cast<int>(it->geometry.x / x), static_cast<int>(it ->geometry.y / x),
static_cast<int>(it->geometry.width / x), static_cast<int>(it->geometry.height/ x));
Expand Down
2 changes: 1 addition & 1 deletion deepin-system-monitor-main/gui/xwin_kill_preview_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef XWIN_KILL_PREVIEW_WIDGET_H
#define XWIN_KILL_PREVIEW_WIDGET_H

#include "config.h"
#include "../config.h"
#include <QWidget>
#ifdef WAYLAND_SESSION_TYPE
#include <KF5/KWayland/Client/clientmanagement.h>
Expand Down
4 changes: 4 additions & 0 deletions deepin-system-monitor-main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "settings.h"
#include "gui/main_window.h"
#include "common/perf.h"
#include "dbus/dbus_object.h"

#include <DApplication>
#include <DApplicationSettings>
Expand All @@ -42,6 +43,9 @@ using namespace common::init;

int main(int argc, char *argv[])
{
//=======通知已经打开的进程
if (!DBusObject::getInstance().registerOrNotify())
return 0;
//Judge if Wayland
WaylandSearchCentered();
//
Expand Down
3 changes: 2 additions & 1 deletion deepin-system-monitor-plugin-popup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ check_include_files("sys/random.h" HAVE_SYS_RANDOM_H)
include(CheckSymbolExists)
check_symbol_exists(syscall "unistd.h" HAVE_SYS_CALL)
check_symbol_exists(SYS_getrandom "sys/syscall.h" HAVE_SYS_CALL)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include(FindPkgConfig)

find_package(Qt5 COMPONENTS Core REQUIRED)
Expand Down Expand Up @@ -67,6 +66,7 @@ include_directories(${LIB_UDEV_INCLUDE_DIRS})
#include_directories(${QGSettings_INCLUDE_DIRS})

include_directories(${MAIN_APP_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)

FILE(GLOB_RECURSE SRCS "*.h" "*.cpp")

Expand Down Expand Up @@ -238,6 +238,7 @@ SET(CPP_PROCESS
${MAIN_APP_DIR}/process/process_controller.cpp
)
set(APP_HPP
${CMAKE_HOME_DIRECTORY}/config.h
application.h
${HPP_MODEL}
${HPP_SYSTEM}
Expand Down
21 changes: 0 additions & 21 deletions deepin-system-monitor-plugin-popup/config.h.in

This file was deleted.

9 changes: 4 additions & 5 deletions deepin-system-monitor-plugin-popup/gui/cpu_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,13 @@ bool CpuWidget::eventFilter(QObject *target, QEvent *event)
return QWidget::eventFilter(target, event);
}

void CpuWidget::mousePressEvent(QMouseEvent *event)
void CpuWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
if (event->type() == QMouseEvent::MouseButtonDblClick) {
DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_CPU");
}
DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_CPU");
return;
}
return QWidget::mousePressEvent(event);
return QWidget::mouseDoubleClickEvent(event);
}

void CpuWidget::changeFont(const QFont &font)
Expand Down
4 changes: 2 additions & 2 deletions deepin-system-monitor-plugin-popup/gui/cpu_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public slots:
bool eventFilter(QObject *target, QEvent *event) override;

//!
//! \brief mousePressEvent 鼠标压下事件,唤醒系统监视器主进程,并跳转到CPU详情界面
//! \brief mouseDoubleClickEvent 鼠标压下事件,唤醒系统监视器主进程,并跳转到CPU详情界面
//! \param event
//!
void mousePressEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;

private:
void initConnection();
Expand Down
Loading

0 comments on commit f90a103

Please sign in to comment.