diff --git a/src/View.cpp b/src/View.cpp index cc797f9a..b12d8500 100644 --- a/src/View.cpp +++ b/src/View.cpp @@ -341,3 +341,13 @@ HANDLE View::handle() const { return m_thisObj; } + +void View::setAboutToBeDestroyed() +{ + m_aboutToBeDestroyed = true; +} + +bool View::aboutToBeDestroyed() const +{ + return m_aboutToBeDestroyed; +} diff --git a/src/View.h b/src/View.h index 9b789ae3..e0c48b62 100644 --- a/src/View.h +++ b/src/View.h @@ -252,6 +252,13 @@ public: /// @brief returns whether this view is inside the specified window bool isInWindow(std::shared_ptr window) const; + /// @brief If true, it means destruction hasn't happen yet but is about to happen. + /// Useful when a controller is under destructions and wants all related views to stop painting or + /// doing anything that would call back into the controller. + /// If false, it doesn't mean anything, as not all controllers are using this. + void setAboutToBeDestroyed(); + bool aboutToBeDestroyed() const; + /// @Returns a list of child views virtual QVector> childViews() const = 0; @@ -274,6 +281,7 @@ protected: private: bool m_freed = false; bool m_inDtor = false; + bool m_aboutToBeDestroyed = false; const QString m_id; const Type m_type; }; diff --git a/src/qtquick/views/FloatingWindow_qtquick.cpp b/src/qtquick/views/FloatingWindow_qtquick.cpp index ba083711..3d1005d8 100644 --- a/src/qtquick/views/FloatingWindow_qtquick.cpp +++ b/src/qtquick/views/FloatingWindow_qtquick.cpp @@ -126,7 +126,7 @@ FloatingWindow_qtquick::~FloatingWindow_qtquick() // Avoid a bunch of QML warnings and constraints being violated at destruction. // Also simply avoiding unneeded work, as QML is destroying stuff 1 by 1 if (auto dropArea = m_controller->dropArea()) - asView_qtquick(dropArea)->setWindowIsBeingDestroyed(true); + asView_qtquick(dropArea)->setAboutToBeDestroyed(); setParent(static_cast(nullptr)); if (qobject_cast(m_quickWindow)) // QObject cast just to make sure the QWindow is not in ~QObject already diff --git a/src/qtquick/views/View_qtquick.cpp b/src/qtquick/views/View_qtquick.cpp index cb150276..46af9946 100644 --- a/src/qtquick/views/View_qtquick.cpp +++ b/src/qtquick/views/View_qtquick.cpp @@ -115,12 +115,14 @@ View_qtquick::View_qtquick(KDDockWidgets::Controller *controller, Type type, } connect(this, &QQuickItem::widthChanged, this, [this] { - onResize(View::size()); - updateGeometry(); + if (!aboutToBeDestroyed()) { // If Window is being destroyed we don't bother + onResize(View::size()); + updateGeometry(); + } }); connect(this, &QQuickItem::heightChanged, this, [this] { - if (!m_windowIsBeingDestroyed) { // If Window is being destroyed we don't bother + if (!aboutToBeDestroyed()) { // If Window is being destroyed we don't bother onResize(View::size()); updateGeometry(); } @@ -798,11 +800,6 @@ QVector> View_qtquick::childViews() const return result; } -void View_qtquick::setWindowIsBeingDestroyed(bool is) -{ - m_windowIsBeingDestroyed = is; -} - void View_qtquick::setIsWrapper() { m_isWrapper = true; diff --git a/src/qtquick/views/View_qtquick.h b/src/qtquick/views/View_qtquick.h index a9e4b313..61d9c3e1 100644 --- a/src/qtquick/views/View_qtquick.h +++ b/src/qtquick/views/View_qtquick.h @@ -158,9 +158,6 @@ public: void setMouseTracking(bool enable) override; QVector> childViews() const override; - // TODOv2: Check if this is still needed - void setWindowIsBeingDestroyed(bool is); - // TODOv2: Check if this is still needed void setIsWrapper(); @@ -196,7 +193,6 @@ private: Qt::WindowFlags m_windowFlags; int m_widgetAttributes = 0; // Qt::WidgetAttribute Qt::FocusPolicy m_focusPolicy = Qt::NoFocus; - bool m_windowIsBeingDestroyed = false; bool m_mouseTrackingEnabled = false; bool m_isWrapper = false; // TODOv2: What's this about QRect m_normalGeometry;