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
nemory
Posts: 216
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi
Accepted Solution

Problem : You must reimplement QApplication::notify() and catch all exceptions there

I'm getting this problem in my headless service project. 

 

Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.

 

Has someone encountered this and have a solution please? Or how should I reimplement so I can catch exceptions?

Please use plain text.
Developer
nemory
Posts: 216
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: Problem : You must reimplement QApplication::notify() and catch all exceptions there

I found this and tried http://rohieb.wordpress.com/2010/07/08/qt-throw-exceptions-from-signals-and-slots/

 

But looks like cascades application requires to subclass bb::cascades::Application, and cannot subclass QApplication

 

please any help?

Please use plain text.
BlackBerry Development Advisor
shaque
Posts: 231
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem : You must reimplement QApplication::notify() and catch all exceptions there

You could try catching the exception as follows and share some more information on the exception.

 

In your application class:

bool Application::notify(QObject* receiver, QEvent* e) {
	try {
		qDebug() << "## trying to notify application..";
		return QCoreApplication::notify(receiver, e);
	} catch (std::exception& e) {
		qDebug() << "## !!FATAL!! Exception thrown: " << e.what();
	}
	return false;
}

 

You should also check if you are running out of heap memory. Too early to say if you are, but I have seen this before for headless. To check heap usage, please see:

http://supportforums.blackberry.com/t5/Native-Development-Knowledge/Memory-limits-of-a-Headless-app/...

Please use plain text.
Developer
nemory
Posts: 216
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: Problem : You must reimplement QApplication::notify() and catch all exceptions there

Thank you so much Shaque. Snap2Chat recently got approved and I will work on it for now. I will update this post after I try it. I thank you so much Shaque :smileyhappy:

Please use plain text.
Developer
nemory
Posts: 216
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: Problem : You must reimplement QApplication::notify() and catch all exceptions there

[ Edited ]

Thanks much shaque.

 

I tried pasting your code to my cpp file and also in the hpp file. I'm getting errors. 

 

I also did tried inserting it in the class Application { // here  }

 

where can  I put it? really sorry not a qt expert here. :smileysad:

 

Hpp File I put

 

bool notify(QObject* receiver, QEvent* e);

 and in cpp

 

cpp.png

 

 

Please use plain text.
Developer
nemory
Posts: 216
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: Problem : You must reimplement QApplication::notify() and catch all exceptions there

I'm getting this too

 

MemoryInfoPrivate::event - Low memory 1
Process 69251271 dispatched low memory signal, priority = 1 number of receivers = 1

 

is this the low memory heap?

Please use plain text.
Developer
nemory
Posts: 216
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: Problem : You must reimplement QApplication::notify() and catch all exceptions there

this is my pro file

 

APP_NAME = MessengerHeadlessService

 

CONFIG += qt warn_on

 

include(config.pri)

 

LIBS += -lbb -lbbsystem -lbbplatform
QT += xml
QT += network

Please use plain text.
Developer
nemory
Posts: 216
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: Problem : You must reimplement QApplication::notify() and catch all exceptions there

Problem solved! I don't know what really fixed it. 

 

But I was preparing a dummy empty UI project attached with the headles project to send to the headless support team and tried and the messageReceived signal worked this time. it's really odd but now it's solved.Thanks so much Shadid.

Please use plain text.