Results 1 to 6 of 6

Thread: If GPS is unavailable, application crashes!!!

  1. #1
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default If GPS is unavailable, application crashes!!!

    Hi All,

    If I deselect all GPS methods in Settings >> Application Manager >> Positioning >> Positioning methods (which I think results the same as no GPS available) in my N8 phone, my application crashes.

    code is something like:
    in .h file
    QGeoPositionInfoSource *locationDataSource;

    in .cpp file
    if (!locationDataSource)
    {
    locationDataSource = QGeoPositionInfoSource::createDefaultSource(this);
    locationDataSource->setPreferredPositioningMethods(QGeoPositionInfoSo urce::AllPositioningMethods);

    ...

    locationDataSource->startUpdates();

    }

    The application crashes as soon as the controller reaches "locationDataSource->setPreferredPositioningMethods(QGeoPositionInfoSo urce::AllPositioningMethods);"
    as I think QGeoPositionInfoSource::AllPositioningMethods would not match anything.

    Is there a way to handle this problem so that my application does not crash even if GPS is unavailable?

    I have tried used exception handling but even that has not worked. I don't exactly know what kind of exception this case would throw and thus I used catch(const std::exception& e) and obviously it has not worked.

    Can anyone please help me with this problem?

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: If GPS is unavailable, application crashes!!!

    So maybe you should check first if the pointer returned is valid before using it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    wizarda (25th January 2011)

  4. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: If GPS is unavailable, application crashes!!!

    Quote Originally Posted by wizarda View Post
    Qt Code:
    1. locationDataSource = QGeoPositionInfoSource::createDefaultSource(this);
    2. locationDataSource->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
    To copy to clipboard, switch view to plain text mode 
    Are you serious? what happened to the basic NULL checking? As wysota pointed out its a null pointer problem. But really.. how are you writing GPS application without Basic NULL checking?

  5. The following user says thank you to nish for this useful post:

    wizarda (25th January 2011)

  6. #4
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: If GPS is unavailable, application crashes!!!

    Thanks guys...

  7. #5

    Default Re: If GPS is unavailable, application crashes!!!

    Wizarda.. did u solve this issue... can you help me with pointers
    Crashed with " Process 758, thread 759 stopped at 0x78e3d4bc: A data abort exception has occurred."
    Finished.

    ####### Sample Code ########
    locationDataSource =
    QGeoPositionInfoSource::createDefaultSource(this); >>>>>>>>> Code crashed immediately after this statement.. .

    if (locationDataSource == NULL)
    {
    QMessageBox m;
    m.setText("Location source NULL ");
    m.exec();
    }

  8. #6

    Default Re: If GPS is unavailable, application crashes!!!

    Solved,Initialize the locationDataSource = NULL

Similar Threads

  1. QModelIndexList crashes application on destruct
    By mstegehu in forum Qt Programming
    Replies: 10
    Last Post: 19th May 2010, 08:58
  2. Application crashes when it has a particular name
    By hunsrus in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2010, 20:50
  3. Application crashes
    By waynew in forum Newbie
    Replies: 1
    Last Post: 2nd November 2009, 10:31
  4. QtStyles and Application Crashes
    By vladozar in forum Qt Programming
    Replies: 0
    Last Post: 19th September 2009, 14:59
  5. My application crashes
    By sophister in forum Qt Programming
    Replies: 13
    Last Post: 27th April 2009, 07:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.