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
Posts: 139
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: problems debugging a problem

Yes, I have those. I also have others. I will look at a clean up function. This is a good lead as I'm not explicitly cleaning up, especially on some custom signals/slots.

Thanks for the tip!
bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: problems debugging a problem

[ Edited ]

@BBSJDev, I meant another problem:

 

In C++ signals are disconnected automatically when target object is destroyed, in QML they aren't.

 

So, every

x.connect(y)

should have a corresponding

x.disconnect(y)

 

In Qt signals can be disconnected in Component.onDestruction, but there's no destruction event in Cascades. Smiley Sad

 

So, a possible workaround is creating a JavaScript helper function such as disconnectSignals() and call it manually before destroying dynamically created objects:

Item {
onCreationCompleted: {
... connect signals
} function disconnectSignals() { ... disconnect signals } } ... myComponent.disconnectSignals() myComponent.destroy()

 

Another method is using QtQuick's Connection element which works in Cascades and can be instantiated in attachedObjects. It handles disconnection automatically. Some details:

http://supportforums.blackberry.com/t5/Native-Development/QML-Connections-Element/m-p/2063301#M9550

 

upd:

What would happen if I connect some signals and slots between a QThread (in c++) and a custom object and that QThread is destroyed (either is told to quit() or or just runs it's course and exits)? Are there "half open" connections that linger?

 

Both thread and worker objects should be deleted, in this case all signals will be disconnected automatically. This KB article shows the pattern:

http://supportforums.blackberry.com/t5/tkb/articleprintpage/tkb-id/Cascades@tkb/article-id/7

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: problems debugging a problem

@zmey I realise that but the OP was talking about threads with a custom object. I see you addressed that in your update. However if that custom object is not in the worker or thread and is a QML object there is still the possibility of zombie connections.


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: problems debugging a problem

@BBSJdev: I didn't see this post initially, was responding from latest email notification. Smiley Happy

Btw, if objects which emit signals (worker & thread) are destroyed, I think the signals will be disconnected even if they were connected to QML item.

Disconnecting them manually is needed only when QML target item is destroyed before the thread quits.

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 139
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: problems debugging a problem

ok, so i found this.  it looks a bit odd to me.  Is this normal?  Looking at the Variables tab in Debug View...

 

the 'this' object also shows the same recursion.  

 

QObject-recur.png

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: problems debugging a problem

I'd say not, this could definately be the source of your problem.

 

Can you post the lines around the code from which the recursive QObject is created?

 


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: problems debugging a problem

@zmey I would have been very surprised if rogue signals were the cause of such a huge spike (and it looks possibly like they won't be the cause). However I think the subject of connections and when and where you need to disconnect confuses a lot of people so it sounds like a good subject for an article and I see you haven't written one yet, so? Smiley Wink


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 139
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: problems debugging a problem

An article about good practices for signal and slot handling, especially surrounding when or whether you *should disconnect would be a good article.

I'm going through the code now. I must be doing setParent(this) or something somewhere.

Happy to have a good lead!

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Developer
Posts: 139
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: problems debugging a problem

i haven't found anything obvious yet, still digging... 

 

I have run into a problem though and I have no idea what's going on... when i try to run in debug mode now, the app takes *forever* to start up - like 7-8 minutes.

 

I found this in the debug output: "Cascades server failed to start - exiting application"

 

and the Debug tab in Debug view shows a thread has been killed.

 

no idea why this was working and now is not.

 

hack, slash.  :/

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: problems debugging a problem