QSqlQuery Access violation by out of scope