|
3 | 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | 4 | #include "dccobject.h" |
5 | 5 |
|
| 6 | +#include "dccapp.h" |
6 | 7 | #include "dccobject_p.h" |
7 | 8 |
|
8 | 9 | #include <QLoggingCategory> |
@@ -45,7 +46,7 @@ DccObject::Private::~Private() |
45 | 46 | m_page->deleteLater(); |
46 | 47 | m_page = nullptr; |
47 | 48 | } |
48 | | - if (m_parent) { |
| 49 | + if (m_parent && m_parent->p_ptr) { |
49 | 50 | m_parent->p_ptr->removeChild(q_ptr); |
50 | 51 | } |
51 | 52 | while (!m_children.isEmpty()) { |
@@ -177,7 +178,7 @@ const QVector<DccObject *> &DccObject::Private::getChildren() const |
177 | 178 |
|
178 | 179 | int DccObject::Private::getIndex() const |
179 | 180 | { |
180 | | - return m_parent ? m_parent->p_ptr->getChildren().indexOf(q_ptr) : -1; |
| 181 | + return (m_parent && m_parent->p_ptr) ? m_parent->p_ptr->getChildren().indexOf(q_ptr) : -1; |
181 | 182 | } |
182 | 183 |
|
183 | 184 | DccObject *DccObject::Private::getChild(int childPos) const |
@@ -295,7 +296,7 @@ void DccObject::setWeight(quint32 weight) |
295 | 296 | { |
296 | 297 | if (p_ptr->m_weight != weight) { |
297 | 298 | p_ptr->m_weight = weight; |
298 | | - if (p_ptr->m_parent) { |
| 299 | + if (p_ptr->m_parent && p_ptr->m_parent->p_ptr) { |
299 | 300 | p_ptr->m_parent->p_ptr->updatePos(this); |
300 | 301 | } |
301 | 302 | Q_EMIT weightChanged(p_ptr->m_weight); |
@@ -442,11 +443,16 @@ DccObject *DccObject::currentObject() |
442 | 443 | void DccObject::setCurrentObject(DccObject *obj) |
443 | 444 | { |
444 | 445 | if (p_ptr->m_currentObject != obj) { |
445 | | - if (p_ptr->m_currentObject) { |
446 | | - Q_EMIT p_ptr->m_currentObject->deactive(); |
447 | | - } |
| 446 | + DccObject *oldObject = p_ptr->m_currentObject; |
448 | 447 | p_ptr->m_currentObject = obj; |
449 | | - Q_EMIT currentObjectChanged(p_ptr->m_currentObject); |
| 448 | + |
| 449 | + DccApp *app = DccApp::instance(); |
| 450 | + if (!app || !app->isBatchUpdating()) { |
| 451 | + if (oldObject) { |
| 452 | + Q_EMIT oldObject->deactive(); |
| 453 | + } |
| 454 | + Q_EMIT currentObjectChanged(p_ptr->m_currentObject); |
| 455 | + } |
450 | 456 | } |
451 | 457 | } |
452 | 458 |
|
|
0 commit comments