www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Access violation connecting a signal / slot

reply Enjoys Math <enjoysmath gmail.com> writes:
I have a class or struct (have tried both; same error):

module track_changes;

import std.array;
import std.signals;

class TrackChanges(T)
{
private:
    T[] _stack;
    int _current = 0;
public:
    mixin Signal!(T);

    TrackChanges opAssign(TrackChanges x) {
       this = x();
       return this;
    }
    T opAssign(T x) {
       if (x != this.opCall()) {
          insertInPlace(_stack, ++_current, x);
       }
       return x;
    }
    T opCall() {
       return _stack[_current];
    }
}

I've tried these two approaches (tried both; same error):

class MyClass : TrackChanges!MyClass {

}

class MyClass
{
     int b;
     TrackChanges!MyClass changes;
}

Both result in an access violation within the `std.signals` 
library upon calling connect in my main() program.
Oct 16 2018
parent Enjoys Math <enjoysmath gmail.com> writes:
Solved:

I forgot to initialize some member variable along the way, which 
is a class so needed to be new'd.

Thanks.
Oct 16 2018