Commit 8338e9c3 authored by Dominik Charousset's avatar Dominik Charousset

Fix segfault in composed behavior

parent 817ea66b
......@@ -84,8 +84,9 @@ public:
}
template <class SelfPointer>
unit_t init_selfptr(SelfPointer selfptr) {
self = selfptr;
unit_t init_selfptr(SelfPointer x) {
CAF_ASSERT(x != nullptr);
self = x;
return unit;
}
......
......@@ -21,6 +21,7 @@
#define CAF_COMPOSABLE_STATE_BASED_ACTOR_HPP
#include "caf/stateful_actor.hpp"
#include "caf/message_handler.hpp"
namespace caf {
......
......@@ -54,6 +54,8 @@ public:
template <class SelfPointer>
unit_t init_selfptr(SelfPointer x) {
CAF_ASSERT(x != nullptr);
self = x;
return unit(static_cast<Ts*>(this)->init_selfptr(x)...);
}
......
......@@ -42,7 +42,7 @@ public:
"cannot create a pointer view to an unrelated actor type");
}
typed_actor_pointer(const std::nullptr_t&) : view_(nullptr) {
typed_actor_pointer(std::nullptr_t) : view_(nullptr) {
// nop
}
......@@ -55,6 +55,18 @@ public:
return view_.ctrl();
}
template <class Supertype>
typed_actor_pointer& operator=(Supertype* ptr) {
using namespace caf::detail;
static_assert(tl_subset_of<
type_list<Sigs...>,
typename Supertype::signatures
>::value,
"cannot assign pointer of unrelated actor type");
view_ = ptr;
return *this;
}
private:
typed_actor_view<Sigs...> view_;
};
......
......@@ -41,6 +41,11 @@ public:
// nop
}
typed_actor_view& operator=(scheduled_actor* ptr) {
self_ = ptr;
return *this;
}
/****************************************************************************
* spawn actors *
****************************************************************************/
......@@ -105,6 +110,7 @@ public:
/// @private
actor_control_block* ctrl() const {
CAF_ASSERT(self_ != nullptr);
return actor_control_block::from(self_);;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment