QSqlQuery throwing a SIGABRT on .clear() or cleanup
Solved
General and Desktop
-
My program is crashing when a QSqlQuery object is either being cleared or deleted, but only if the query is on an invalid entry. So if I call "while (query.next())" it will crash, but if I stop it at the second to last entry then it will delete just fine. It's returning valid values from the database, so I know the database is opening properly and that QSqlQuery is reading properly.
int cycleCount = 0; int zoneid; QSqlQuery query(sql); //sql is a QSqlDatabase declared elsewhere query.exec("SELECT MAX(zoneid) FROM zone_settings"); query.next(); int maxCount = query.value(0).toInt(); zoneList = new zoneInfo[maxCount]; //Custom struct pointer declared elsewhere //query.clear() //Does not crash query.exec("SELECT zoneid FROM zone_settings"); //while (query.next()) //{ // cycleCount++; // zoneid = query.value(0).toInt(); // zoneList[zoneid].id = zoneid; //} //query.clear(); //Crashes int returnedValues = query.size(); for (int i = 0; i < returnedValues - 1; i++){ query.next(); cycleCount++; zoneid = query.value(0).toInt(); zoneList[zoneid].id = zoneid; } query.clear(); //Does not crash
-
@Xenthan said in QSqlQuery throwing a SIGABRT on .clear() or cleanup:
zoneList[zoneid].id
Check for zoneid out of bounds or better use an appropriate container instead c magic.
-
@Xenthan said in QSqlQuery throwing a SIGABRT on .clear() or cleanup:
zoneList[zoneid].id
Check for zoneid out of bounds or better use an appropriate container instead c magic.
-
-
-