PDA

View Full Version : revertAll() failure question



mtnbiker66
16th March 2012, 19:17
All --

Got a weird problem -- I have a QSqlTableModel that I would like to roll back any changes a user had made to it via a QTableView, but when my cancel slot executes, my app just hangs on the command and I have to kill it from a task manager...I'm sure it's the revertAll command because if I make no edits and cancel I don't have a problem (plus I encased it in qDebug() statements)

Here's the definition of my model


swaymodel = new QSqlTableModel(this);
swaymodel->setTable("sway");
swaymodel->setEditStrategy(QSqlTableModel::OnManualSubmit);
swaymodel->setHeaderData(0, Qt::Horizontal, QObject::tr("Period"));
swaymodel->setHeaderData(1, Qt::Horizontal, QObject::tr("Phase"));
swaymodel->setFilter (QString("sway_dataset_id = %1").arg(rig_dataset));
swaymodel->select();

ui->SwayTV->setModel(swaymodel);



Here is the slot connected to a Cancel tool button

void RAOEntryDialog::on_RAO_CancelTB_clicked()
{
sway_model->revertAll();
RAOEntryDialog::close();
}


And the table definition


//***********************************
//* Create table for Sway data... *
//***********************************
sql_command = "create table sway (sway_period INTEGER NOT NULL, ";
sql_command.append("sway_phase INTEGER NOT NULL, ");
sql_command.append("sway_seq_no INTEGER NOT NULL, ");
sql_command.append("sway_dataset_id INTEGER NOT NULL, ");
sql_command.append("sway_rig_id INTEGER NOT NULL, ");
sql_command.append("sway_user_name TEXT NOT NULL, ");
sql_command.append("sway_activity_date DATE NOT NULL)");


I found that if I can get the same result if instead of reverting I, "sway_model->select ()" but I am curious if anyone has had this happen, too...


Kodi