KDDockWidgets API Documentation
2.0
Loading...
Searching...
No Matches
source
src
core
ViewGuard.cpp
Go to the documentation of this file.
1
/*
2
This file is part of KDDockWidgets.
3
4
SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5
Author: Waqar Ahmed <waqar.ahmed@kdab.com>
6
7
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9
Contact KDAB at <info@kdab.com> for commercial licensing options.
10
*/
11
12
#include "
ViewGuard.h
"
13
#include "
View.h
"
14
#include "core/View_p.h"
15
16
using namespace
KDDockWidgets
;
17
using namespace
KDDockWidgets::Core
;
18
19
ViewGuard::ViewGuard
(
View
*view)
20
{
21
setView(
view
);
22
}
23
24
ViewGuard::ViewGuard
(
const
ViewGuard
&other)
25
{
26
setView(other.
view
());
27
}
28
29
ViewGuard::~ViewGuard
()
30
{
31
clear
();
32
}
33
34
ViewGuard::operator bool()
const
35
{
36
return
!isNull();
37
}
38
39
bool
ViewGuard::isNull
()
const
40
{
41
return
v ==
nullptr
;
42
}
43
44
View
*
ViewGuard::operator->
()
45
{
46
return
v;
47
}
48
49
const
View
*
ViewGuard::operator->
()
const
50
{
51
return
v;
52
}
53
54
void
ViewGuard::clear
()
55
{
56
v =
nullptr
;
57
m_onDestroy.
disconnect
();
58
}
59
60
View
*
ViewGuard::view
()
const
61
{
62
return
v;
63
}
64
65
ViewGuard
&
ViewGuard::operator=
(
View
*view)
66
{
67
setView(
view
);
68
return
*
this
;
69
}
70
71
ViewGuard
&
ViewGuard::operator=
(
const
ViewGuard
&other)
72
{
73
if
(
this
== &other)
74
return
*
this
;
75
76
setView(other.
view
());
77
return
*
this
;
78
}
79
80
void
ViewGuard::setView(
View
*view)
81
{
82
if
(
view
== v)
83
return
;
84
85
if
(
view
&&
view
->
inDtor
()) {
86
// We don't care about views that are already being in DTOR. They count as already deleted
87
// for what's ViewGuard concerned. This is rare anyway, would need to require some
88
// reentrancy.
89
view
=
nullptr
;
90
}
91
92
clear
();
93
v =
view
;
94
95
if
(v) {
96
m_onDestroy = v->
d
->beingDestroyed.connect([
this
] { v =
nullptr
; });
97
}
98
}
ViewGuard.h
KDBindings::ConnectionHandle::disconnect
void disconnect()
Definition
signal.h:101
KDDockWidgets::Core::ViewGuard
This class provides a weak reference to a view i.e., it becomes null automatically once a View is des...
Definition
ViewGuard.h:27
KDDockWidgets::Core::ViewGuard::~ViewGuard
~ViewGuard()
Definition
ViewGuard.cpp:29
KDDockWidgets::Core::ViewGuard::operator->
View * operator->()
Definition
ViewGuard.cpp:44
KDDockWidgets::Core::ViewGuard::view
View * view() const
Definition
ViewGuard.cpp:60
KDDockWidgets::Core::ViewGuard::ViewGuard
ViewGuard(View *v)
Definition
ViewGuard.cpp:19
KDDockWidgets::Core::ViewGuard::operator=
ViewGuard & operator=(View *)
Definition
ViewGuard.cpp:65
KDDockWidgets::Core::ViewGuard::clear
void clear()
Definition
ViewGuard.cpp:54
KDDockWidgets::Core::ViewGuard::isNull
bool isNull() const
Definition
ViewGuard.cpp:39
KDDockWidgets::Core::View
Definition
core/View.h:48
KDDockWidgets::Core::View::d
Private *const d
Definition
core/View.h:250
KDDockWidgets::Core::View::inDtor
bool inDtor() const
Returns whether the DTOR is currently running. freed() might be true while inDtor false,...
Definition
core/View.cpp:112
KDDockWidgets::Core
Definition
Config.h:27
KDDockWidgets
Class to abstract QAction, so code still works with QtQuick and Flutter.
Definition
KDStlContainerAdaptor.h:427
View.h
© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated by doxygen 1.9.8