Hello everyone,
I am using QT to manage a connection to a MS Access Database. It is reading data without issue, issue comes after using a record to
Code is below. I get the exception in attached image when the records destructor is called. I tried calling clear on the record after use, but that also created a issue.
ErrorMsg.jpg
Below is method concerned
void DataManager::setRelationalTableData(std::unique_ptr<tableData> data)
{
if (HelperFunctions::tableNameMatchesEnum(mCurrentRelationalTableModel->tableName(), data->tableName))
{
mCurrentRelationalTableModel
->setEditStrategy
(QSqlTableModel::EditStrategy::OnManualSubmit);
for (ushort row = 0; row < mCurrentRelationalTableModel->rowCount(); row++)
{
auto relateTableRecord = mCurrentRelationalTableModel->record(row);
auto tableData = data->tableContents.find(row);
for (ushort dataItr = 0; dataItr < data->tableContents.size(); dataItr++)
{
relateTableRecord.
setValue(QString::fromStdString(data
->tableHeaders.
at(dataItr
)),
QString::fromStdString(tableData
->second.
at(dataItr
)));
}
mCurrentRelationalTableModel->setRecord(row, relateTableRecord);
}
mCurrentRelationalTableModel->submitAll();
}
}
void DataManager::setRelationalTableData(std::unique_ptr<tableData> data)
{
if (HelperFunctions::tableNameMatchesEnum(mCurrentRelationalTableModel->tableName(), data->tableName))
{
mCurrentRelationalTableModel->setEditStrategy(QSqlTableModel::EditStrategy::OnManualSubmit);
for (ushort row = 0; row < mCurrentRelationalTableModel->rowCount(); row++)
{
auto relateTableRecord = mCurrentRelationalTableModel->record(row);
auto tableData = data->tableContents.find(row);
for (ushort dataItr = 0; dataItr < data->tableContents.size(); dataItr++)
{
relateTableRecord.setValue(QString::fromStdString(data->tableHeaders.at(dataItr)), QString::fromStdString(tableData->second.at(dataItr)));
}
mCurrentRelationalTableModel->setRecord(row, relateTableRecord);
}
mCurrentRelationalTableModel->submitAll();
}
}
To copy to clipboard, switch view to plain text mode
EDIT:: The relationaltablemodel is being updated with new data, although this is never submitted as the crash occurs before submitall
Many thanks in advance
Bookmarks