Error handling (try catch)

  • Hi everyone!
    Is there any way to catch or detect access violation error?
    construction like
    QString *str;
    should throw error, but it doesn't.

  • The access violation error isn't thrown (exceptions are thrown not errors) - it occurs when you access memory that you don't own.

    Anyway you can initialize your pointers with 0 (null pointer) and then first check for 0 and only then call a member-function (to be a little more safer you can assign 0 to the pointer after you delete it then you detect the attempt to call function after the pointer is deleted)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.