File tree Expand file tree Collapse file tree 2 files changed +5
-28
lines changed Expand file tree Collapse file tree 2 files changed +5
-28
lines changed Original file line number Diff line number Diff line change @@ -29,16 +29,11 @@ connection::connection() noexcept : slot_(nullptr)
29
29
connection::connection (slot_base& slot)
30
30
: slot_(&slot)
31
31
{
32
- if (slot_)
33
- slot_->add_destroy_notify_callback (this , ¬ify_slot_invalidated);
34
32
}
35
33
36
34
37
35
connection::connection (const connection& c) : slot_(c.slot_)
38
36
{
39
- // Let the connection forget about the signal handler when the handler object dies:
40
- if (slot_)
41
- slot_->add_destroy_notify_callback (this , ¬ify_slot_invalidated);
42
37
}
43
38
44
39
connection&
@@ -50,8 +45,6 @@ connection::operator=(const connection& src)
50
45
51
46
connection::~connection ()
52
47
{
53
- if (slot_)
54
- slot_->remove_destroy_notify_callback (this );
55
48
}
56
49
57
50
bool
@@ -97,22 +90,10 @@ connection::operator bool() const noexcept
97
90
}
98
91
99
92
void
100
- connection::set_slot (slot_base* sl)
93
+ connection::set_slot (const sigc::internal::weak_raw_ptr< slot_base>& sl)
101
94
{
102
- if (slot_)
103
- slot_->remove_destroy_notify_callback (this );
104
-
105
95
slot_ = sl;
106
-
107
- if (slot_)
108
- slot_->add_destroy_notify_callback (this , ¬ify_slot_invalidated);
109
96
}
110
97
111
- void
112
- connection::notify_slot_invalidated (notifiable* data)
113
- {
114
- auto self = static_cast <connection*>(data);
115
- self->slot_ = nullptr ;
116
- }
117
98
118
99
} /* namespace sigc */
Original file line number Diff line number Diff line change 20
20
#define SIGC_CONNECTION_HPP
21
21
#include < sigc++config.h>
22
22
#include < sigc++/functors/slot_base.h>
23
+ #include < sigc++/weak_raw_ptr.h>
23
24
24
25
namespace sigc
25
26
{
@@ -31,7 +32,7 @@ namespace sigc
31
32
*
32
33
* @ingroup signal
33
34
*/
34
- struct SIGC_API connection : public notifiable
35
+ struct SIGC_API connection
35
36
{
36
37
/* * Constructs an empty connection object. */
37
38
connection () noexcept ;
@@ -89,17 +90,12 @@ struct SIGC_API connection : public notifiable
89
90
explicit operator bool () const noexcept ;
90
91
91
92
private:
92
- void set_slot (slot_base* sl);
93
-
94
- /* * Callback that is executed when the referred slot is destroyed.
95
- * @param data The connection object notified (@p this).
96
- */
97
- static void notify_slot_invalidated (notifiable* data);
93
+ void set_slot (const sigc::internal::weak_raw_ptr<slot_base>& sl);
98
94
99
95
/* Referred slot. Set to zero from notify().
100
96
* A value of zero indicates an "empty" connection.
101
97
*/
102
- slot_base* slot_;
98
+ sigc::internal::weak_raw_ptr< slot_base> slot_;
103
99
};
104
100
105
101
} /* namespace sigc */
You can’t perform that action at this time.
0 commit comments