0

I am experiencing a frustrating crash on BB10 cascades.

I have a "Dashboard" page which has a dynamic amount of items in it. The items themselves have contextActions. One of the actions being to remove the item from the dashboard. However when I remove the item(s) the app just force-closes.

An extract of the code is below:

Dashboard.qml

...
Container {
    id: ticketContainer
    bottomPadding: 20
    horizontalAlignment: HorizontalAlignment.Fill
}
...
function refreshTickets() {
    ticketContainer.removeAll();
    for (var i=0; i<tickets.length; i++) {
        var obj = ticketDefinition.createObject();
        obj.bookingRef = tickets[i].bookingReference;
        obj.bookingDate = ticket[i].bookingDate;
        ticketContainer.add(obj);
    }
}

Ticket.qml (used for ticketDefinition)

...
contextActions: [
    ActionSet {
        ActionItem {
            id: actionUnTrack
            title: "Remove this Ticket"
            onTriggered: {
                untrackTicket(bookingRef);
            }
        }
    }
]
...

In the ticket.qml it calls a method untrackTicket in a utility class which when done will call the refreshTickets() in Dashboard.qml. As soon as the refresh happens the app closes.

There are no logs for the crash.

Any suggestions on how to tackle this problem?

hyarion
  • 2,251
  • 2
  • 17
  • 28

1 Answers1

0

In untrackTicket, are you freeing the memory pointed by obj (the Control) that you've added using ticketContainer.add(obj) ?

I suspect that the crash is happening at:

ticketContainer.removeAll();

removeAll() documentation says: Removes all of a container's controls and frees up their memory.

If you have already freed that memory, removeAll will try to delete an object that have already been delete and thus will crash.

nbilal
  • 1,069
  • 2
  • 10
  • 21
  • Thanks. I've used removeAll in other places and it works fine, it seems to just be an issue when one of the controls is responsible for the triggering action. I've managed to fix it by using ticketContainer.remove() instead which does not clear the memory for the object. It's not ideal but in this case it should work as my app doesn't allow more than 2 tickets per user and the tickets will be cleared from memory when the page is closed. – hyarion Nov 21 '13 at 07:25