I'm working on a Qt project and often when I make a bunch of changes and build, when I run the program I get a random segmentation fault somewhere in the Qt framework.
To fix it I have to rebuild and then it goes away.
I found another person who had this issue and they received this answer:
from: Segmentation fault in Qt application framework
This makes it sound as though your build system isn't recognizing a dependency and that a change to that class definition isn't triggering a rebuild of something that should be recompiled when the definition changes.
Make sure class LevelIndicator is defined in exactly one place (generally that would be a header file that gets included by whatever modules need to use a LevelIndicator object). Also make sure that any global/static instances of LevelIndicator objects are following the one definition rule.
So that makes sense to me, however each class is defined in only one place, with #ifndef guards to prevent double inclusions. So how can I avoid this?