Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/dde-control-center/dccmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,8 @@ void DccManager::doShowPage(QPointer<DccObject> obj, const QString &cmd)
if (triggeredObj->pageType() == DccObject::MenuEditor && !triggeredObj->getChildren().isEmpty()) {
triggeredObj = triggeredObj->getChildren().first();
}

m_batchUpdating = true;
DccObject *tmpObj = triggeredObj;
tmpObj->setCurrentObject(nullptr);
tmpObj->active(QString());
Expand All @@ -850,6 +852,7 @@ void DccManager::doShowPage(QPointer<DccObject> obj, const QString &cmd)
tmpObj = tmpObjParent;
}
if (!tmpObj) {
m_batchUpdating = false;
return;
}
modules.append(tmpObj);
Expand Down Expand Up @@ -881,6 +884,8 @@ void DccManager::doShowPage(QPointer<DccObject> obj, const QString &cmd)
// 更新当前对象
m_currentObjects = modules;
m_triggeredObjects = triggeredObjs;
m_batchUpdating = false;

Q_EMIT triggeredObjectsChanged(m_triggeredObjects);
if (auto *lastObj = m_currentObjects.last(); lastObj != m_activeObject) {
m_activeObject = lastObj;
Expand Down
4 changes: 4 additions & 0 deletions src/dde-control-center/dccmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#include <DConfig>
#include <DSysInfo>

#include <QDBusContext>

Check warning on line 12 in src/dde-control-center/dccmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusContext> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusMessage>

Check warning on line 13 in src/dde-control-center/dccmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusMessage> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QObject>

Check warning on line 14 in src/dde-control-center/dccmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <atomic>

Check warning on line 15 in src/dde-control-center/dccmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <atomic> not found. Please note: Cppcheck does not need standard library headers to get proper results.

QT_BEGIN_NAMESPACE
class QWindow;
Expand Down Expand Up @@ -52,6 +53,8 @@

inline const QVector<DccObject *> &triggeredObjects() const override { return m_triggeredObjects; }

inline bool isBatchUpdating() const override { return m_batchUpdating; }

Q_INVOKABLE DccApp::UosEdition uosEdition() const;
Q_INVOKABLE Dtk::Core::DSysInfo::ProductType productType() const;

Expand Down Expand Up @@ -145,6 +148,7 @@
QDBusMessage m_showMessage;

QHash<QString, QVector<DccObject *>> m_objMap; // 映射对象名称到对象指针列表,用于快速查找
std::atomic<bool> m_batchUpdating{false};
};
} // namespace dccV25
#endif // DCCMANAGER_H
11 changes: 9 additions & 2 deletions src/dde-control-center/plugin/DccLoader.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick

Expand All @@ -7,10 +7,17 @@ Loader {
property Item dccObjItem: null

function updateDccObjItem() {
if (dccObj) {
if (dccObj && dccObjItem) {
dccObj.parentItem = dccObjItem
}
}

Component.onDestruction: {
if (dccObj && dccObj.parentItem === dccObjItem) {
dccObj.parentItem = null
}
}

enabled: dccObj && dccObj.enabledToApp
// asynchronous: true
sourceComponent: dccObj ? dccObj.page : null
Expand Down
4 changes: 3 additions & 1 deletion src/dde-control-center/plugin/dccapp.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef DCCAPP_H
Expand Down Expand Up @@ -62,7 +62,9 @@
virtual void setSidebarWidth(int width);
virtual void setAnimationMode(AnimationMode mode);

virtual bool isBatchUpdating() const { return false; }

public Q_SLOTS:

Check warning on line 67 in src/dde-control-center/plugin/dccapp.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If Q_SLOTS is a macro then please configure it.
virtual DccObject *object(const QString &name);
virtual void addObject(DccObject *obj);
virtual void removeObject(DccObject *obj);
Expand Down
20 changes: 13 additions & 7 deletions src/dde-control-center/plugin/dccobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "dccobject.h"

#include "dccapp.h"
#include "dccobject_p.h"

#include <QLoggingCategory>

Check warning on line 9 in src/dde-control-center/plugin/dccobject.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickItem>
Expand Down Expand Up @@ -45,7 +46,7 @@
m_page->deleteLater();
m_page = nullptr;
}
if (m_parent) {
if (m_parent && m_parent->p_ptr) {
m_parent->p_ptr->removeChild(q_ptr);
}
while (!m_children.isEmpty()) {
Expand Down Expand Up @@ -177,7 +178,7 @@

int DccObject::Private::getIndex() const
{
return m_parent ? m_parent->p_ptr->getChildren().indexOf(q_ptr) : -1;
return (m_parent && m_parent->p_ptr) ? m_parent->p_ptr->getChildren().indexOf(q_ptr) : -1;
}

DccObject *DccObject::Private::getChild(int childPos) const
Expand Down Expand Up @@ -295,7 +296,7 @@
{
if (p_ptr->m_weight != weight) {
p_ptr->m_weight = weight;
if (p_ptr->m_parent) {
if (p_ptr->m_parent && p_ptr->m_parent->p_ptr) {
p_ptr->m_parent->p_ptr->updatePos(this);
}
Q_EMIT weightChanged(p_ptr->m_weight);
Expand Down Expand Up @@ -442,11 +443,16 @@
void DccObject::setCurrentObject(DccObject *obj)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这应该是在主线程里被触发的吧,是线性的吧,会存在多个交叉被setCurrentObject么,

{
if (p_ptr->m_currentObject != obj) {
if (p_ptr->m_currentObject) {
Q_EMIT p_ptr->m_currentObject->deactive();
}
DccObject *oldObject = p_ptr->m_currentObject;
p_ptr->m_currentObject = obj;
Q_EMIT currentObjectChanged(p_ptr->m_currentObject);

DccApp *app = DccApp::instance();
Comment on lines +446 to +449
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Reordered deactivation vs. current object update may introduce behavior changes in slots.

Previously, deactive() was emitted before updating m_currentObject, so slots handling deactive() and then calling currentObject() would still see the old object. With the new ordering (update m_currentObject first, then emit deactive(oldObject)), those same slots will now see the new object, which is a behavior change that can affect existing plugin code. If the goal is just to suppress signals during batch updates, you could keep the original ordering and gate both signals with isBatchUpdating() instead.

if (!app || !app->isBatchUpdating()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看下ai的评论,另外app为空不需要执行了吧,

if (oldObject) {
Q_EMIT oldObject->deactive();
}
Q_EMIT currentObjectChanged(p_ptr->m_currentObject);
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/dde-control-center/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ void LoadPluginTask::createData()
soObj->setParent(nullptr);
}
}
if (m_pManager->isDeleting()) {
if (dataObj)
delete dataObj;
if (soObj)
delete soObj;
return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接return,不走 这个正常么, Q_EMIT m_pManager->updatePluginStatus(m_data, DataEnd, ": create data finished. elapsed time :" + QString::number(timer.elapsed()));

}
if (dataObj) {
m_data->data = dataObj;
}
Expand Down Expand Up @@ -507,6 +514,7 @@ void PluginManager::loadMain(PluginData *plugin)
void PluginManager::createModule(QQmlComponent *component)
{
if (isDeleting()) {
component->deleteLater();
return;
}
PluginData *plugin = component->property("PluginData").value<PluginData *>();
Expand Down Expand Up @@ -536,6 +544,7 @@ void PluginManager::createModule(QQmlComponent *component)
void PluginManager::createMain(QQmlComponent *component)
{
if (isDeleting()) {
component->deleteLater();
return;
}
PluginData *plugin = component->property("PluginData").value<PluginData *>();
Expand Down
Loading