Commit d8bfa9ae authored by Leander Schulten's avatar Leander Schulten
Browse files

Fix Bugs and add error checking

parent 363cb422
...@@ -41,8 +41,8 @@ Programm::Programm(const QJsonObject &o):NamedObject(o,&syncServiceClassName),ID ...@@ -41,8 +41,8 @@ Programm::Programm(const QJsonObject &o):NamedObject(o,&syncServiceClassName),ID
} }
void Programm::addDeviceProgramm(const QJsonObject &o){ void Programm::addDeviceProgramm(const QJsonObject &o){
programms.push_back(new DeviceProgramm(IDBase<Device>::getIDBaseObjectByID(o["device"].toString().toLong()), programms.push_back(new DeviceProgramm(IDBase<Device>::getIDBaseObjectByID(o["device"]),
IDBase<ProgrammPrototype>::getIDBaseObjectByID(o["programmPrototype"].toString().toLong()), IDBase<ProgrammPrototype>::getIDBaseObjectByID(o["programmPrototype"]),
o["offset"].toDouble())); o["offset"].toDouble()));
emit deviceProgrammAdded(programms.back()); emit deviceProgrammAdded(programms.back());
connect(programms.back(),&DeviceProgramm::destroyed,this,&Programm::deviceProgrammDeleted); connect(programms.back(),&DeviceProgramm::destroyed,this,&Programm::deviceProgrammDeleted);
......
...@@ -36,7 +36,13 @@ public: ...@@ -36,7 +36,13 @@ public:
*/ */
Q_SLOT void setSpeed(double s){if(s==speed)return;speed=s;emit speedChanged(speed);} Q_SLOT void setSpeed(double s){if(s==speed)return;speed=s;emit speedChanged(speed);}
double getSpeed()const{return speed;} double getSpeed()const{return speed;}
DeviceProgramm(Device * device,ProgrammPrototype * programmPrototype,double offset):QObject(device),programmPrototype(programmPrototype),offset(offset),device(device){connect(programmPrototype,&ProgrammPrototype::destroyed,this,&DeviceProgramm::programmPrototypeDeleted);} DeviceProgramm(Device * device,ProgrammPrototype * programmPrototype,double offset):QObject(device),programmPrototype(programmPrototype),offset(offset),device(device){
if(!device)
throw new std::runtime_error("Nullpointer Exception: device is nullptr");
if(!programmPrototype)
throw new std::runtime_error("Nullpointer Exception: programmPrototype is nullptr");
connect(programmPrototype,&ProgrammPrototype::destroyed,this,&DeviceProgramm::programmPrototypeDeleted);
}
bool setProgrammPrototype(ProgrammPrototype * p){ bool setProgrammPrototype(ProgrammPrototype * p){
if(p->devicePrototype!=device->prototype){ if(p->devicePrototype!=device->prototype){
return false; return false;
......
Supports Markdown
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