[SailfishDevel] Seg fault in QML ListView when connected to SQL model

Dmitriy Purgin dpurgin at gmail.com
Mon Sep 7 03:42:19 UTC 2015


Hi,

can you tell please what are you trying to achieve, e.g. what view are you
building? Why do you set explicit height for the ListView anyway?

Cheers
Dmitriy

2015-09-06 14:00 GMT+06:00 coding <coding at userspace.se>:

> Hi,
>
> I am developing a sailfish app using a QML ListView which is connected to
> a model using a sqlite db. The model is based on QSqlTableModel, but
> extended so it can be used by the QML ListView. I have found a segmentation
> fault related to the ListView when trying to delete an element in the
> ListView using the ContextMenu. I considered reporting this as a bug to
> qt.io, but I decided to post it here first.
>
> I have tried to reproduce the problem with a short code snippet, but since
> the bug needs the SQL model it was hard to get it very short.
> QML code: http://pastebin.com/b5zkFm1q
> C++ code: http://pastebin.com/5RN269kH
> gdb trace: http://pastebin.com/4ZdCbZd6
> app debug output: http://pastebin.com/C4N9T1tP
>
> How to reproduce:
> 1. Start app (in emulator, I don't have my jolla tablet yet)
> 2. Long press the last element in the list and select "Delete" from the
> context menu.
> (It can also be triggered from other elements in the list, but the code at
> pastebin is based on the last element)
>
> The bug is triggered if the bottom of ContextMenu is rendered below the
> height of the ListView.
> When long pressing the n:th element in the ListView it will crash if:
> listviewHeight < n*elementHeight+(n-1)*spacing + contextMenuHeight
>
> Example (using pastebin code):
> ListView is 338 pixels high and have 4 items inside
> Each item is 44 pixels high
> Spacing is 1 pixel
> Context menu is 160 pixels high
>
> When clicking on the 4:th item (starting counting from 1) the total height
> of items + spacing + context menu will be:
> 4*(44) + (4-1)*1 + 160 = 339 pixels
> listviewHeight=338 => crash
> listviewHeight=339 => not crash
>
> When deleting the element in the list I do two things:
> 1. model->removeRow(index) //Everything is fine after this is executed
> 2. model->submitAll() //Results in segmentation fault
>
> I have tried replacing the model with a QML ListModel, created/filled in
> QML, but then the bug is not triggered.
>
> Any input would be appreciated!
> _______________________________________________
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to
> devel-unsubscribe at lists.sailfishos.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20150907/9e161195/attachment.html>


More information about the Devel mailing list