Quote Originally Posted by mentalmushroom View Post
is it safe to use local static QMutex instance?
I don't know, probably not, however it doesn't make much sense to do so anyway.

Also could you, please, explain what did you mean saying Yes, mutex protects the data, but we protect it from the code, don't we? Here is more complete sample. Do you find it wrong?
You are protecting code (the function) and not the data. If the data is shared, there are at least two places where you access it from thus having a local mutex (static or not) doesn't make sense. Your last snippet is better (however we only see one function using it) and is not prone to the problem you stated (since it is initialized before the program is launched).