Results 1 to 5 of 5

Thread: Application crashes when I delete the character pointer array

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: Application crashes when I delete the character pointer array

    How I can protect from application crash with try catch when any exception occur.
    The error in your code did not result in a C++ exception; it was most likely a segmentation fault caused when the QByteArray instance on the stack went out of scope and tried to delete the internal memory you had already deleted in line 6. Try/catch blocks do not trap segmentation faults or other C++ signals (not to be confused with Qt "signals"). In order to trap a C++ segmentation fault signal, you need to install a signal handler for SIGSEGV.

    However, once your program's memory get corrupted by something like a segmentation fault, it is not a good idea to simply trap it and go on running as if nothing has happened. It is far better to 1) find and fix these errors in the debugger instead of pretending they don't exist, and 2) if you do trap them with a signal handler, then the best thing to do is to tell the user that it happened and exit quickly. It really isn't safe to do anything else, because you don't know what damage the SIGSEGV has caused.

  2. The following user says thank you to d_stranz for this useful post:

    arunkumaraymuo1 (14th February 2013)

Similar Threads

  1. Replies: 5
    Last Post: 13th March 2021, 09:07
  2. Delete character from file
    By kaszewczyk in forum Newbie
    Replies: 2
    Last Post: 11th March 2010, 18:07
  3. qstringlist array crashes program
    By chrisb123 in forum Newbie
    Replies: 4
    Last Post: 23rd October 2009, 15:03
  4. QVector crashes when array size is big
    By Sheng in forum Qt Programming
    Replies: 49
    Last Post: 27th February 2009, 22:13
  5. How to create QPixmap from unsigned character array?
    By rashidbutt in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 18:25

Tags for this Thread

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.