Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top