Replace QPointer with a ViewGuard

This commit is contained in:
Sergio Martins
2022-07-09 16:29:48 +01:00
parent e3c08593b9
commit 233736a20b
2 changed files with 4 additions and 5 deletions

View File

@@ -195,7 +195,7 @@ bool StateNone::handleMouseButtonPress(Draggable *draggable, QPoint globalPos, Q
return false;
q->m_draggable = draggable;
q->m_draggableGuard = draggable->asView()->asQObject();
q->m_draggableGuard = draggable->asView();
q->m_pressPos = globalPos;
q->m_offset = draggable->mapToWindow(pos);
Q_EMIT q->mousePressed();
@@ -214,7 +214,7 @@ StatePreDrag::~StatePreDrag() = default;
void StatePreDrag::onEntry()
{
qCDebug(state) << "StatePreDrag entered" << q->m_draggableGuard.data();
qCDebug(state) << "StatePreDrag entered" << q->m_draggableGuard;
WidgetResizeHandler::s_disableAllHandlers = true; // Disable the resize handler during dragging
}

View File

@@ -75,8 +75,7 @@ class DOCKS_EXPORT DragController : public MinimalStateMachine, public EventFilt
Q_OBJECT
Q_PROPERTY(bool isDragging READ isDragging NOTIFY isDraggingChanged)
public:
enum State
{
enum State {
State_None = 0,
State_PreDrag,
State_Dragging
@@ -139,7 +138,7 @@ private:
QVector<Draggable *> m_draggables;
Draggable *m_draggable = nullptr;
QPointer<QObject> m_draggableGuard; // Just so we know if the draggable was destroyed for some reason
ViewGuard m_draggableGuard = nullptr; // Just so we know if the draggable was destroyed for some reason
std::unique_ptr<WindowBeingDragged> m_windowBeingDragged;
Controllers::DropArea *m_currentDropArea = nullptr;
bool m_nonClientDrag = false;