0

I have an issue with a list/detail pattern. I have an Article class, inheriting from QObject, defining some properties (title, updated and content being the ones that matters for now). To populate my (QML) ListView, I have a C++ GroupDataModel, filled with some Article*. Here's my list's onTriggered:

onTriggered: {
    if (indexPath.length > 1) {
        currentArticle = dataModel.data(indexPath);
        var page = articlePageDefinition.createObject();
        nav.push(page)
    }
}

As you can guess, the articlePageDefinition defines a page using the upper currentArticle property.

Now, when I display the articlePage once, it's working fine. I can go back, click on the same list item, display the same Article details, works great. But when I pick a second article, the app kind of freezes. I can go back in my navigation pane, but I can't click on list items anymore. I tried to add some logs, the onTriggered is stuck on currentArticle = dataModel.data(indexPath);. At this point, I can log every property of dataModel.data(indexPath) without any issue. I tried to not create/push the page, simply affect currentArticle and display some of its properties, it's working fine too. I really don't understand what I am doing wrong here, any help appreciated.

In case you need to see more code, everything is here: https://github.com/Kernald/tt-rss-bb10/tree/e29e3b616aa179dd42f66804ecc20a6a45b6bb22

Marc Plano-Lesay
  • 6,808
  • 10
  • 44
  • 75
  • I do not know what could cause your issue, but for sure, I'd advise you not to use Javascript global variable for "currentArticle". Prefer to use property or a function to setData – Benoit Apr 16 '13 at 14:39
  • I tried this morning to replace the `currentArticle` property by an `article` property in the detail page, it's working fine. You're right that it's the good way to do it, and I'll keep it this way. But I'm still curious about the reason of the original issue. – Marc Plano-Lesay Apr 16 '13 at 15:21

2 Answers2

1

Here what can cause the problem your are having:

  1. You create the articlePage and bind it's data to the "currentArticle" global variable
  2. When you go back the articlePage is not deleted.
  3. You open an other instance of this same articlePage. The last one still bind its data to the same currentArticle instance.
  4. When you go back and click another item: the previous articlePage still exists in memory. It binds to "currentArticle". The problem is, it's not the data of "currentArticle" that has changed but the object referenced by "currentArticle". The Qml binder just fails then.
Benoit
  • 1,922
  • 16
  • 25
  • That seems logical. Is there any way to unbind a property or force the page deletion? – Marc Plano-Lesay Apr 16 '13 at 16:34
  • Just write on your navigationPane: onPopTransitionEnded: { page.destroy(); } – Benoit Apr 16 '13 at 17:22
  • The page is effectively destroyed now, but it doesn't fix the initial issue. Weirder thing I forgot to mention in the initial post, once the app "crashed but not really", I can't stop it (the icon stays grayed out) unless I reboot the phone. – Marc Plano-Lesay Apr 16 '13 at 17:29
0

I had a similar behavior of my app, but I did not inspect your github code if the reason can be the same. I think you can verify that more quickly than me.
When removing and adding a list item with the same index, the code gets stucked. I removed an entry on user action and added a new one at that place, and it got stuck. This is a known issue to BB10, I found here: https://developer.blackberry.com/cascades/download/releasenotes/#known

Schlangi
  • 1,135
  • 1
  • 9
  • 19
  • No, I don't remove items in the list. I add them when I initialize the list, then it's only a list/detail pattern, where the list is read-only. However, your catch will be usefull in a couple of days, thanks... – Marc Plano-Lesay Apr 23 '13 at 12:23