Verified Commit d1f25cea authored by Romain De Laage De Bellefaye's avatar Romain De Laage De Bellefaye 🌳
Browse files

Add more explicits error for database and make init of griffeath works

parent 6e0145ff
No preview for this file type
...@@ -432,6 +432,6 @@ INSERT INTO Cellules VALUES( ...@@ -432,6 +432,6 @@ INSERT INTO Cellules VALUES(
INSERT INTO Cellules VALUES( INSERT INTO Cellules VALUES(
2, 2,
3, 3,
3, 4,
4 4
); );
...@@ -48,7 +48,7 @@ void Database::initEnsEtat(Automate& a) const { ...@@ -48,7 +48,7 @@ void Database::initEnsEtat(Automate& a) const {
query.exec(); query.exec();
if(!query.first()) if(!query.first())
throw "Unable to select this object"; throw "Unable to select this object (ensemble)";
EnsembleEtat& ens = a.getEnsemble(); EnsembleEtat& ens = a.getEnsemble();
ens.reset(); ens.reset();
...@@ -75,7 +75,7 @@ Fonction* Database::getFonction(Automate& a) const { ...@@ -75,7 +75,7 @@ Fonction* Database::getFonction(Automate& a) const {
query.exec(); query.exec();
if(!query.first()) if(!query.first())
throw "Unable to select this object"; throw "Unable to select this object (function)";
Fonction* fonction = new Fonction(a.getEnsemble().getEtat(query.value("defaut").toInt())); Fonction* fonction = new Fonction(a.getEnsemble().getEtat(query.value("defaut").toInt()));
...@@ -162,7 +162,7 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const { ...@@ -162,7 +162,7 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const {
query.exec(); query.exec();
if(!query.first()) if(!query.first())
throw "Unable to select this object"; throw "Unable to select this object (neighbourhood)";
int type = query.value("type").toInt(); int type = query.value("type").toInt();
...@@ -235,7 +235,7 @@ Reseau& Database::getReseau(int idReseau) const { ...@@ -235,7 +235,7 @@ Reseau& Database::getReseau(int idReseau) const {
reseau.bindValue(":id", idReseau); reseau.bindValue(":id", idReseau);
reseau.exec(); reseau.exec();
if(!reseau.first()) if(!reseau.first())
throw "Can't select!"; throw "Can't select (reseau) !";
Reseau* r = new Reseau(reseau.value("h").toUInt(), reseau.value("l").toUInt()); Reseau* r = new Reseau(reseau.value("h").toUInt(), reseau.value("l").toUInt());
//remplissage du réseau //remplissage du réseau
...@@ -250,7 +250,7 @@ Reseau& Database::getReseau(int idReseau) const { ...@@ -250,7 +250,7 @@ Reseau& Database::getReseau(int idReseau) const {
cellule.bindValue(":j", static_cast<int>(j)); cellule.bindValue(":j", static_cast<int>(j));
cellule.exec(); cellule.exec();
if(!cellule.first()) if(!cellule.first())
throw "Can't select!"; throw "Can't select (cell) !";
while(static_cast<int>(r->getReseau()[i][j].getIndEtat()) != cellule.value("etat").toInt()) while(static_cast<int>(r->getReseau()[i][j].getIndEtat()) != cellule.value("etat").toInt())
r->getReseau()[i][j].incrementerEtat(); r->getReseau()[i][j].incrementerEtat();
} }
...@@ -498,7 +498,7 @@ void Database::initSingletonAutomate(const QString& modele) const ...@@ -498,7 +498,7 @@ void Database::initSingletonAutomate(const QString& modele) const
reseau.exec(); reseau.exec();
if(!reseau.first()) if(!reseau.first())
throw "Can't select!"; throw "Can't select (automaton) !";
Automate::getInstance().setTitle(reseau.value(0).toString().toStdString()); Automate::getInstance().setTitle(reseau.value(0).toString().toStdString());
Automate::getInstance().setAuthor(reseau.value(1).toString().toStdString()); Automate::getInstance().setAuthor(reseau.value(1).toString().toStdString());
......
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