문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top