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

Regular Contributor
Posts: 70
Registered: ‎09-06-2012
My Device: Developer
My Carrier: Bell Mobility
Accepted Solution

BBM itemAdded signal emitted twice

I have coded to display BBM profile box entries and to add and remove those entries using c++ and cascades qml.

My program kept hanging after I requested an item be added or removed from the box. Tracing the program in debug I found that the memory adress of my page and option cointrols was reset to zero. Thought it might have to do with async comminications so reworked it so I uesed my own sognals and slots although didn't see that I needed them. Same problem. So in my routine to update the page I simply said if page address is 0 just exit. Thought at least I wouldn't hang even if it didn't work. 


Well, to my surprie, program worked perfectly - almost instantly updating page.


So I traced it through again.


1. Load Page contents

2. request item be added 

3. receive itemAdded signal - memory already  0's but only to do with page and its controls, rest of object properties OK.

4. Load Page routine returns becuse of 0 addresses

5. itemAdded signal received - memory is ok

6. Load Page contents - routine is enetered and page is updated

7. app page is ready to respond


Two itemRemoved signals are received when item removed,


When there are already 3 items I receive two itemAdded's and one itemRemoved.


The two things I don't undersatnd are 1)  why are two signals sent and 2) why and how can memory be set to zero for page and its controls and only for those properties.


It has occurred to me that there might be another instance of my object  with an uninitialized page, each instance receiveing a signal, but don't know how that would happen.


Anyone have a similar experience or know how I can tell if I have somehow created multiple instances of the object.


BlackBerry Development Advisor
Posts: 15,882
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: BBM itemAdded signal emitted twice

I tried out the bbmprofilebox sample app on a couple different OS versions and didn't see duplicates fired.  You could try that sample to rule out an OS versus application issue.


Likely the easiest way to catch duplicate registrations is to set a break point where you are connecting the itemAdded and itemRemoved signals to your slots. 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Regular Contributor
Posts: 70
Registered: ‎09-06-2012
My Device: Developer
My Carrier: Bell Mobility

Re: BBM itemAdded signal emitted twice



Just testing my fix. I was using the breakpoints that is how I  knew about the duplicate signals. It took a couple of tries of stepping through my program until I found the right sequence. And, just as it happened a light went on. My object was attached to the page so it called the constructor and then my program also called the constructor and then completed the initialization.


Tried different approaches and one that worked was letting page call constructor, finding the object on the page and then in c++ completing the set up, saving object address ... before displaying the page.