Hi,
I've stumbled upon something very annoying :
I have a model that inherits from QSqlTableModel. A SilicaListView shows the
data. This is very easy to do, thanks to Qt/QML :)
Each list item has a ContextMenu with a "Delete" entry that allows the user to
delete the item. It runs a remorse, and, at the end of the remorse, the item is
deleted from the model (and the database).
Again, this works quite well... until you try to delete several items at the
same time
A QSqlTableModel can have 3 different edit strategies : OnManualSubmit,
OnRowChange or OnFieldChange.
If I set it to "OnManualSubmit", the item is deleted from the model, but it
remains in the view and in the database until I call
QSqlTableModel::submitAll(). This method actually commits the changes to the
database, and resets the model by calling QSqlTableModel::select(). Since the
model is resetted, it loses all other running remorses and causes a segfault.
If I set it to "OnFieldChanged", the item is deleted from the model and from
the database, but it will still remain visible in the view. According to the Qt
doc, I should call select() to update the view. But, as we've seen before, this
destroys the other running remorses and also causes a segfault.
I've made a very small app to demonstrate the problem, you can get it here and
try it in your emulator : git clone https://github.com/Frzk/dummy.git
You can use the PullDownMenu to switch between OnManualSubmit and
OnFieldChanged strategies.
How should I deal with this ? This is a very simple case, yet I can't seem to
find a solution :(
All the best,
--
François
___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org