Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Error handling (try catch)
Forum Updated to NodeBB v4.3 + New Features

Error handling (try catch)

Scheduled Pinned Locked Moved C++ Gurus
2 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qxoz
    wrote on 1 Mar 2012, 10:50 last edited by
    #1

    Hi everyone!
    Is there any way to catch or detect access violation error?
    construction like
    @
    QString *str;
    try{
    str.clear();
    }
    catch(...){
    ...
    }
    @
    should throw error, but it doesn't.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zlatomir
      wrote on 1 Mar 2012, 14:20 last edited by
      #2

      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)

      https://forum.qt.io/category/41/romanian

      1 Reply Last reply
      0

      2/2

      1 Mar 2012, 14:20

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved