Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
dkonigs
Posts: 248
Registered: ‎07-25-2008
My Device: Bold 9900

Deleting pages popped from a NavigationPane on back-button

So as we've all figured out by now, NavigationPane no longer has a popAndDelete() function.  That's easy to work around, by just doing both steps ourselves.  However, this also seems to mean that when the user presses the Back button on the UI, it now just calls pop() on the Page without deleting it.

 

Since I almost always do want to delete a page when the user presses the back button, I found this little QML snippet in the updated docs for NavigationPane:


NavigationPane {
    id: navigationPane
    Page {
        . . .

    }

    onPopTransitionEnded: { page.destroy(); }
}
In theory, this does what I want.  In practice, it causes this error message whenever the user presses the Back button:
"Error: Invalid attempt to destroy() an indestructible object"
 
What am I missing here, and what's the easiest way to get back an automatic pop-and-delete behavior when the Page is popped due to user interaction?
Please use plain text.
Developer
dkonigs
Posts: 248
Registered: ‎07-25-2008
My Device: Bold 9900

Re: Deleting pages popped from a NavigationPane on back-button

I should mention that I was able to solve this from C++, soon after posting the previous message.  I connected a slot to the popTransitionEnded signal, and deleted the page from within that slot.  So, pretty much the same thing the docs say should work for QML, but it seems to only actually work in C++.

Please use plain text.
Developer
bbquincar
Posts: 304
Registered: ‎08-14-2012
My Device: PlayBook, Z10, Dev C
My Carrier: Rogers

Re: Deleting pages popped from a NavigationPane on back-button

[ Edited ]

Iv been having the same issuse. App crashes after going back and forth between pages (10) times are more. Have you been able to get this to work in QML I really dont know enough about C++ to input it.

Please show sample if you can thanks

 

 this is the bottom of my app

 

 function setDetailItem(item) {
                // show detail page
                var page = secondPage.createObject();
                page.text = item.title
                page.image = item.image
                nav.push(page)
                onPopTransitionEnded:
                {
                    page.destroy();
                }
            }

 

BlackBerry 10 game reviews for the unknown, small and indie developers. Little games with big dreams. VeryBerryGames.com | Follow @VeryBerryGames | TwoCasualCoders.com | never casual on quality
Please use plain text.
Developer
sgallego84
Posts: 89
Registered: ‎10-18-2012
My Device: BB Z10
My Carrier: -

Re: Deleting pages popped from a NavigationPane on back-button

I have the same issue as dkonigs... Is there any advance about it??

 

Please use plain text.
Developer
yogeshwarp
Posts: 30
Registered: ‎11-09-2012
My Device: Dev Alpha A
My Carrier: Airtel

Re: Deleting pages popped from a NavigationPane on back-button

Also seems to cause a crash in my app if I quickly load a page -> go back and repeat this sequence 3-4 times.

No message is printed on console unfortunately.

 

commenting the page.destroy() line does seem to prevent the crash. Now not doing page.destroy() will it lead to a memory leak? else I will need to keep it on and accept occasional crashes.

Please use plain text.
Developer
BBSJdev
Posts: 6,094
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Deleting pages popped from a NavigationPane on back-button

Also I believe there's a memory leak on pages using this pop and destroy method, can anyone confirm this?

 

Real pain when you are trying to find your own.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Contributor
TheStoof
Posts: 20
Registered: ‎02-21-2012
My Device: Bold 9900
My Carrier: AT&T

Re: Deleting pages popped from a NavigationPane on back-button

NavigationPane {
    Page {
         Container {
              // Layout stuff
                  Button {
         
                       onClicked: {
                            var page = viewPageList.createObject();
                            nav.push(page)
                       }
                   }
          }
     attachedObjects: [
        ComponentDefinition {
            id: viewPageList
            source: "view.qml"
        }
     ]
     onPopTransitionEnded: {
        page.destroy();
    }
}



 

If the page that you're opening has a bottom button, then you should be fine. You're calling the "page" variable and destroying it.

 

For me, I use a TitleBar on some of my pages because it's prettier:

titleBar: TitleBar {
        title: selectedData.datePlayed
        visibility: ChromeVisibility.Visible
        dismissAction: ActionItem {
            id: actionDismiss
            title: "Cancel"
            enabled: true
            onTriggered: {
                pop();
            }
        } // ActionItem
        acceptAction: ActionItem {
            id: actionSave
            title: "Save"
            enabled: false
            onTriggered: {
                pop();
            }
        } // ActionItem
    }

 

Please use plain text.
New Member
xioempire
Posts: 1
Registered: ‎07-16-2013
My Device: Z10
My Carrier: China Mobile

Re: Deleting pages popped from a NavigationPane on back-button

Yes. Delete the page in C++ slot works for me too.
For more reference, find the C++ example on http://developer.blackberry.com/cascades/reference/bb__cascades__navigationpane.html
Please use plain text.