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
raju504
Posts: 86
Registered: ‎05-21-2012
My Device: Blackberry 10 Dev Alpha

qml function is executing more no. of times..!

Hi All!

 

    I am setting a class object as context property to a qml. I have a signal in that class and connecting that signal to the qml function(connection statement is written in qml and it is written in onCreationCompleted() slot of that page). I have succeeded connecting to the function in qml but its getting executed as many no. of times as I visit that page. How to solve this problem!!!

 

here is my connection statement...

network.detailsRecieved.connect(page.populateDetailedStatement);

 

Thanks!

- Raju

 

- Raju
Developer
dishooom
Posts: 103
Registered: ‎12-31-2012
My Device: Blackberry 9810

Re: qml function is executing more no. of times..!

You could disconnect() the slot from the signal, if you dont want it to be notified. Or alternatively, you could keep a count of the unique page visits and disconnect the connection when its > 1.

 

_ Dishooom

 

Hope this helps... :Angel:

Developer
raju504
Posts: 86
Registered: ‎05-21-2012
My Device: Blackberry 10 Dev Alpha

Re: qml function is executing more no. of times..!

how to call disconnect in qml...!

- Raju
Developer
dishooom
Posts: 103
Registered: ‎12-31-2012
My Device: Blackberry 9810

Re: qml function is executing more no. of times..!

[ Edited ]

For a javascript function displayvalues , i make a connection to a signal (for instance Application thumbnail) in QML as follows....

 Application.thumbnail.connect(displayvalues); 

 

and disconnect it as follows.....

 

 Application.thumbnail.disconnect(displayvalues); 

 

_Dishooom

 

Hope this helps :Angel:

Developer
raju504
Posts: 86
Registered: ‎05-21-2012
My Device: Blackberry 10 Dev Alpha

Re: qml function is executing more no. of times..!

       I have a component definition in which a page exists. when a button is clicked I am creating object of that component definition and pushing into a navigation pane. And I am connecting the c++ signal to the page's javascript function in the onCreationCompleted() slot of the page. If I visit the page again and again the signal is emitting that many times.

 

     But disconnecting the js function from the signal is not working...! is there any way to specify uniqueconnection like in Qt to the connection statement...!

 

- Raju

- Raju
Developer
sketch34
Posts: 54
Registered: ‎05-23-2012
My Device: Developer

Re: qml function is executing more no. of times..!

[ Edited ]

I'm having this exact problem. Calling disconnect() in QML didn't work for me either.

----
I know exactly where the problem *might* be.
Developer
sketch34
Posts: 54
Registered: ‎05-23-2012
My Device: Developer

Re: qml function is executing more no. of times..!

In my case it may be related to this Qt/QML issue here: http://stackoverflow.com/questions/8849031/dead-qml-elements-receiving-signals where QML objects that had been destroyed were still receiving signals.

 

The solution in that case was to disconnect signals in the onDestruction handler, but unfortunately Cascades doesn't appear to have any counterpart to the creationCompleted() signal for destruction: https://developer.blackberry.com/cascades/reference/bb__cascades__uiobject.html

----
I know exactly where the problem *might* be.
Developer
sketch34
Posts: 54
Registered: ‎05-23-2012
My Device: Developer

Re: qml function is executing more no. of times..!

Ok solved! What I said above was the issue for me. Pages still receive signals after they are destroyed (seems like a bug?)

 

I fixed it by adding the disconnect() call to the onPopTransitionEnded in the parent NavigationPane of the Page that was doing the connect() as follows:

 

    onPopTransitionEnded: {
        if(page.objectName == "detailsPage")
        {
            console.log("Disconnecting signal from detailsPage...");
            WebAPI.requestDetailsResult.disconnect(page.handleDetailsResult);
        }
        page.destroy();
    }

 

----
I know exactly where the problem *might* be.