--First off, this might be a Newbie question, but it might not, so feel free to move it.

Anyways, in my application I have a variety of objects (like QSettings) and I think deleting them after they're used is a good way to free up memory. So, it seems I can't delete an object without an error being generated or my app freezing later.

So one time, I have an object defined in my header:

Qt Code:
  1. ...
  2. private:
  3. settings settingsChanger;
  4. ...
To copy to clipboard, switch view to plain text mode 

The "settings" class is a QObject subclass that has a single QSettings object defined in the header and contains a variety of members to change values in QSettings. So, in my code after I'm done with settingChanger, naturally I want to delete it. So I use deleteLater() but my program just has a "signal" and the debugger stops it.

Doing the same thing with a pointer to the object, and having

Qt Code:
  1. ...
  2. private:
  3. settings *settingsChanger;
  4. ...
To copy to clipboard, switch view to plain text mode 

And in the definition:
Qt Code:
  1. ...
  2. settingsChanger = new settings(this);
  3. ...
  4. settingsChanger->deleteLater()
  5. ...
To copy to clipboard, switch view to plain text mode 

causes my program to get a signal too. So, I'm not really sure what I'm doing wrong. Should I delete the QSettings in the destructor of my settings class? I thought deleteLater() was a complete failsafe that wouldn't cause problems like this, but am I wrong, or have I made a huge mistake?

Thanks in advance for any advice.

~codeslicer