<div dir="ltr"><div><div><div>Hi,<br><br></div>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? <br><br></div>Cheers<br></div>Dmitriy<br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-09-06 14:00 GMT+06:00 coding <span dir="ltr"><<a href="mailto:coding@userspace.se" target="_blank">coding@userspace.se</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
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 <a href="http://qt.io" rel="noreferrer" target="_blank">qt.io</a>, but I decided to post it here first.<br>
<br>
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.<br>
QML code: <a href="http://pastebin.com/b5zkFm1q" rel="noreferrer" target="_blank">http://pastebin.com/b5zkFm1q</a><br>
C++ code: <a href="http://pastebin.com/5RN269kH" rel="noreferrer" target="_blank">http://pastebin.com/5RN269kH</a><br>
gdb trace: <a href="http://pastebin.com/4ZdCbZd6" rel="noreferrer" target="_blank">http://pastebin.com/4ZdCbZd6</a><br>
app debug output: <a href="http://pastebin.com/C4N9T1tP" rel="noreferrer" target="_blank">http://pastebin.com/C4N9T1tP</a><br>
<br>
How to reproduce:<br>
1. Start app (in emulator, I don't have my jolla tablet yet)<br>
2. Long press the last element in the list and select "Delete" from the context menu.<br>
(It can also be triggered from other elements in the list, but the code at pastebin is based on the last element)<br>
<br>
The bug is triggered if the bottom of ContextMenu is rendered below the height of the ListView.<br>
When long pressing the n:th element in the ListView it will crash if:<br>
listviewHeight < n*elementHeight+(n-1)*spacing + contextMenuHeight<br>
<br>
Example (using pastebin code):<br>
ListView is 338 pixels high and have 4 items inside<br>
Each item is 44 pixels high<br>
Spacing is 1 pixel<br>
Context menu is 160 pixels high<br>
<br>
When clicking on the 4:th item (starting counting from 1) the total height of items + spacing + context menu will be:<br>
4*(44) + (4-1)*1 + 160 = 339 pixels<br>
listviewHeight=338 => crash<br>
listviewHeight=339 => not crash<br>
<br>
When deleting the element in the list I do two things:<br>
1. model->removeRow(index) //Everything is fine after this is executed<br>
2. model->submitAll() //Results in segmentation fault<br>
<br>
I have tried replacing the model with a QML ListModel, created/filled in QML, but then the bug is not triggered.<br>
<br>
Any input would be appreciated!<br>
_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a><br>
</blockquote></div><br></div>