24
24
#include < sigc++/adaptors/adaptor_trait.h>
25
25
#include < sigc++/functors/slot_base.h>
26
26
27
+ #include < memory>
28
+
27
29
namespace sigc
28
30
{
29
31
@@ -49,22 +51,22 @@ struct typed_slot_rep : public slot_rep
49
51
public:
50
52
51
53
/* * The functor contained by this slot_rep object. */
52
- adaptor_type functor_;
54
+ std::unique_ptr< adaptor_type> functor_;
53
55
54
56
/* * Constructs an invalid typed slot_rep object.
55
57
* The notification callback is registered using visit_each().
56
58
* @param functor The functor contained by the new slot_rep object.
57
59
*/
58
60
inline explicit typed_slot_rep (const T_functor& functor)
59
- : slot_rep(nullptr , &destroy, &dup), functor_(functor)
61
+ : slot_rep(nullptr , &destroy, &dup), functor_(std::make_unique<adaptor_type>( functor) )
60
62
{
61
- sigc::visit_each_trackable (slot_do_bind (this ), functor_);
63
+ sigc::visit_each_trackable (slot_do_bind (this ), * functor_);
62
64
}
63
65
64
66
inline typed_slot_rep (const typed_slot_rep& cl)
65
- : slot_rep(cl.call_, &destroy, &dup), functor_(cl.functor_)
67
+ : slot_rep(cl.call_, &destroy, &dup), functor_(std::make_unique<adaptor_type>(* cl.functor_) )
66
68
{
67
- sigc::visit_each_trackable (slot_do_bind (this ), functor_);
69
+ sigc::visit_each_trackable (slot_do_bind (this ), * functor_);
68
70
}
69
71
70
72
typed_slot_rep& operator =(const typed_slot_rep& src) = delete ;
@@ -76,7 +78,7 @@ struct typed_slot_rep : public slot_rep
76
78
{
77
79
call_ = nullptr ;
78
80
destroy_ = nullptr ;
79
- sigc::visit_each_trackable (slot_do_unbind (this ), functor_);
81
+ sigc::visit_each_trackable (slot_do_unbind (this ), * functor_);
80
82
}
81
83
82
84
private:
@@ -88,8 +90,8 @@ struct typed_slot_rep : public slot_rep
88
90
auto self_ = static_cast <self*>(data);
89
91
self_->call_ = nullptr ;
90
92
self_->destroy_ = nullptr ;
91
- sigc::visit_each_trackable (slot_do_unbind (self_), self_->functor_ );
92
- self_->functor_ .~adaptor_type ( );
93
+ sigc::visit_each_trackable (slot_do_unbind (self_), * self_->functor_ );
94
+ self_->functor_ .reset ( nullptr );
93
95
/* don't call disconnect() here: destroy() is either called
94
96
* a) from the parent itself (in which case disconnect() leads to a segfault) or
95
97
* b) from a parentless slot (in which case disconnect() does nothing)
@@ -126,7 +128,7 @@ struct slot_call
126
128
static T_return call_it(slot_rep* rep, type_trait_take_t <T_arg>... a_)
127
129
{
128
130
auto typed_rep = static_cast <typed_slot_rep<T_functor>*>(rep);
129
- return (typed_rep->functor_ ).template operator ()<type_trait_take_t <T_arg>...>(a_...);
131
+ return (* typed_rep->functor_ ).template operator ()<type_trait_take_t <T_arg>...>(a_...);
130
132
}
131
133
132
134
/* * Forms a function pointer from call_it().
0 commit comments