If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
New Developer
sharath_moblie
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: BB 10 App Crashing in device,but working good in simulator

I am guessing and keeping try and catch here and there to catch the exception. like the code shown above.

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

Re: BB 10 App Crashing in device,but working good in simulator

All you've done here is try to catch an exception with setting up the app/scene, the event loop is called later in main.


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.
Developer
BBSJdev
Posts: 6,023
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: BB 10 App Crashing in device,but working good in simulator

The way you are going about this will take you a long time and might not pin point where your problem is, I really do recommend buying, borrowing or begging a real device.

 


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.
Developer
greenmr
Posts: 874
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: BB 10 App Crashing in device,but working good in simulator

[ Edited ]

Actually, the event loop greatly complicates exception catching. Unless you can catch an error very close to the source, the only way to catch random exceptions once the loop has started if you don't know where they originated is to extend the Application class, define your own notify() member function, and put a try-catch around QCoreApplication::notify().

 

Here is somebody else's example of how to do this.

 

I did this in my own app some time ago to figure out where a ramdom crash was coming from, and then left it in place for future use in case I need it.

 

UPDATE: Hmmm, I thought I added this right after posting this message, but it looks like my "edit" didn't take. I wanted to point out that the example link I supplied is from someone doing vanilla Qt development. With Cascades, you MUST extend Application, not QApplication, since the constructor for Application does a lot of necessary initialization for Cascades apps.

 

UPDATE-UPDATE: Just in case it isn't obvious... doing this also means that you have to change the Application instantiation in your main.cpp to instantiate your extended class instead.

 

i.e. change this:

 

Application app( argc, argv );

...to this:

 

myApplication app( argc, argv );

 


BBSJdev wrote:

All you've done here is try to catch an exception with setting up the app/scene, the event loop is called later in main.






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Please use plain text.
New Developer
sharath_moblie
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: BB 10 App Crashing in device,but working good in simulator

Can I write Exceptions into a file lke this?

 

class MyApplication : public Application  {
public:
  MyApplication(int& argc, char ** argv) :
	  Application(argc, argv) { }
  virtual ~MyApplication() { }

  // reimplemented from Application so we can throw exceptions in slots
  virtual bool notify(QObject * receiver, QEvent * event) {
    try {
      return Application::notify(receiver, event);
    } catch(std::exception& e) {
      qCritical() << "Exception thrown:" << e.what();
      QString str(e.what());
      qDebug()<<e.what();
      Helper::writeToLog("\n Caught Exception in RegistrationHandler"+str);
    }
    return false;
  }
};

 

Please use plain text.
New Developer
sharath_moblie
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: BB 10 App Crashing in device,but working good in simulator

I am raising the Division by Zero Exception, at some potion of my code, but I didn't see any thing on console by using above procedure..
Please use plain text.
New Developer
sharath_moblie
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: BB 10 App Crashing in device,but working good in simulator

It is working now..The mistake I did was...After changing the signing keys to some other sign keys...In my bar-descriptor.xml file <Author> Tag was missed. After adding it to my latest bar-descriptor.xml file,It worked for me, Thanks!!!

Please use plain text.
Developer
greenmr
Posts: 874
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: BB 10 App Crashing in device,but working good in simulator

[ Edited ]

I know you got your code working now, but I wanted to answer this question since I think it is an important one. Although at first glance it seems like it would be, divide by zero is NOT a catchable exception, it is a catastrophic shutdown. Once a divide by zero has already happened it is too late to recover from it, the application is in an unstable and undefined state and so the OS will unceremoniously shut it all down, completely bypassing any try-catch blocks in your code.

 

Sometime you will see a divide by zero exception caught, but in this case, the divide by zero never actually happened. Somewhere deep in the library code, a function TESTED the divisor before doing the division and realized it was zero, then threw a divide by zero exception. Unfortunately, such validation before division is not common, and in most cases, the application will just crash ugly when the invalid division is performed.

 

What this means it that whenever you write division code where you aren't certain the divisor can never be zero, you need to test it before doing the division, and raise an exception of your own rather than rely on the application's math library to do it for you.

 


sharath_moblie wrote:
I am raising the Division by Zero Exception, at some potion of my code, but I didn't see any thing on console by using above procedure..





Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Please use plain text.