Qt 4.2.2 and MSVC 2003

I have a class that inherits QThread with a buffer, QMutex, and QWaitCondition for data members.

The run function of the thread does a mutex.lock() and then sends whatever is in the buffer over TCP and then does a wcond.wait(&mutex).

Then whenever the classes event function receives an event it does a mutex.lock() fills the buffer and calls mutex.unlock() wcond.wakeall().

This works great in debug mode, but not in release mode.

I seem to have narrowed it down to whether the system linking option is on console or window. When on console the application works as expected. When you turn off the console by selecting window, the application seems to ignore the QMutex in that if the run function is sending the buffer the event will overwrite the buffer at the same time like they both have the mutex.

I've tried with and without optimization but it's all dependent on that linker system option.

Let me know if you need more information in order to guide me in the right direction. Thanks.