diff --git a/itemis.create.examples.trafficlight.cpp.qt/implementation/main.cpp b/itemis.create.examples.trafficlight.cpp.qt/implementation/main.cpp index d1937a0e..7994a12a 100644 --- a/itemis.create.examples.trafficlight.cpp.qt/implementation/main.cpp +++ b/itemis.create.examples.trafficlight.cpp.qt/implementation/main.cpp @@ -19,22 +19,23 @@ int main(int argc, char *argv[]) return -1; - TrafficLightStateMachine *machine = new TrafficLightStateMachine(nullptr); - sc::qt::SCTimerService *timerService = new sc::qt::SCTimerService(machine); + std::shared_ptr machine = std::make_shared(nullptr); + std::shared_ptr timerService = std::make_shared(nullptr); machine->setTimerService(timerService); + QObject *root = engine.rootObjects().at(0); QObject *control = root->findChild(QString("control")); - QObject::connect(control, SIGNAL(pause()), machine, SLOT(standby())); - QObject::connect(control, SIGNAL(play()), machine, SLOT(operate())); + QObject::connect(control, SIGNAL(pause()), machine.get(), SLOT(standby())); + QObject::connect(control, SIGNAL(play()), machine.get(), SLOT(operate())); QObject *trafficLight = root->findChild(QString("trafficLight")); - QObject::connect(machine, SIGNAL(redOn()), trafficLight, SLOT(redOn())); - QObject::connect(machine, SIGNAL(redOff()), trafficLight, SLOT(redOff())); - QObject::connect(machine, SIGNAL(yellowOn()), trafficLight, SLOT(yellowOn())); - QObject::connect(machine, SIGNAL(yellowOff()), trafficLight, SLOT(yellowOff())); - QObject::connect(machine, SIGNAL(greenOn()), trafficLight, SLOT(greenOn())); - QObject::connect(machine, SIGNAL(greenOff()), trafficLight, SLOT(greenOff())); + QObject::connect(machine.get(), SIGNAL(redOn()), trafficLight, SLOT(redOn())); + QObject::connect(machine.get(), SIGNAL(redOff()), trafficLight, SLOT(redOff())); + QObject::connect(machine.get(), SIGNAL(yellowOn()), trafficLight, SLOT(yellowOn())); + QObject::connect(machine.get(), SIGNAL(yellowOff()), trafficLight, SLOT(yellowOff())); + QObject::connect(machine.get(), SIGNAL(greenOn()), trafficLight, SLOT(greenOn())); + QObject::connect(machine.get(), SIGNAL(greenOff()), trafficLight, SLOT(greenOff())); machine->enter();