Quote Originally Posted by magland View Post
Based on a recent recommendation on this forum I changed my coding habits and use "const QString &" everywhere instead of "QString".... but now I see that I need to be more careful.
It's recommended to pass objects by reference to avoid copying, but on the other hand in Qt it's cheap to copy implicitly shared classes.

Quote Originally Posted by magland View Post
Do you have a recommendation of what precautions I need to take with this?
I was thinking about this for few days and I couldn't come up with any rules. You situation is a bit similar to:
Qt Code:
  1. ...
  2. v.append( v[0] );
To copy to clipboard, switch view to plain text mode 
The argument is passed as reference, but it must be copied when QVector needs to reallocate data. You can easily identify such situation in a single data structure, but the problem arises when the data is passed between many classes. But I would simply classify that as one of those Bad Things(tm) that might happen when you use global variables (or you have cycles in call graph).