Still the ownership problem. 5, why 5? It should be 3...
This commit is contained in:
+8
-3
@@ -6,7 +6,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace VISEQ::BASE {
|
||||
class Connectable : public Draggable {
|
||||
class Connectable : public Draggable, public std::enable_shared_from_this<Connectable> {
|
||||
public:
|
||||
Connectable() {}
|
||||
Connectable(Vec2Df position) : Draggable(position) {}
|
||||
@@ -19,6 +19,10 @@ namespace VISEQ::BASE {
|
||||
bool connecting = false;
|
||||
Vec2Df connecting_position;
|
||||
|
||||
std::shared_ptr<Connectable> getPtr(){
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
virtual void init() {
|
||||
connectables.emplace_back(this);
|
||||
}
|
||||
@@ -36,11 +40,12 @@ namespace VISEQ::BASE {
|
||||
virtual void connect() {
|
||||
if(picked_up){
|
||||
for(auto c : connectables){
|
||||
if(c.get() != this && c->hovering()) {
|
||||
if(c != getPtr() && c->hovering()) {
|
||||
partner = c;
|
||||
c->partner.reset(this);
|
||||
c->partner = getPtr();
|
||||
new_partner = true;
|
||||
partner->new_partner = true;
|
||||
std::cout << "connect use count: " << getPtr().use_count() << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user