If "curve" is derived from QObject, then it is owned by a parent QObject. When you are inside a slot, this ownership is not usually cleaned up until after the slot exits and control returns to the Qt event loop. So when you "delete" a QObject, your code can crash because the parent QObject still thinks it has control of the pointer. Do something like this:

Qt Code:
  1. curve->deleteLater();
  2. curve = nullptr;
To copy to clipboard, switch view to plain text mode 

And be sure to check the value of curve elsewhere in your code to make sure you aren't trying to use a null pointer. deleteLater() tells Qt to delete the object after it has returned control to the event loop, not immediately the way "delete" does.