I have a simple Qt application with two threads a main thread and a worker thread. The main thread supports a QApplication, QMainWindow. The QMainWindow has a textEdit widget. I have sub-classed QEvent to create a MyCustomEvent. MyCustomEvent has a QString member. I have overridden "customEvent" in the QMainWindow object. My "customEvent" method uses insertPlainText to insert the text contained in the QString into the textEdit widget.

I am attempting use"QCoreApplication:: postEvent to post "MyCustomEvent"s from both the worker thread and the main thread.

My problem is: This works really nicely when the program is compiled and run on Ubuntu Linux. It crashes on every exit from my customEvent mentod when compiled and run as a 32-bit windows app from Visual Studion 2010 Qt add-in on 64 bit Windows 7.

The crash occurs after the overridden customEvent method is called. It occurs immediately after the destructor for MyCustomEvent is called. The crash occurs in PostMessageEvent::~PostMessageEvent() short after PostMessageEvent::'scalar deleting destructor', operator delete:, _RTC_CheckEsp.

I have checked my allocation of MyCustomeEvent carefully. It is allocated on the heap, NOT on the stack. The QString it contains is allocated on the heap and is deleted by ~MyCustomEvent.

Note I originally tried using cross thread slots and signals to achieve the communication between the worker thread and gui thread, but again on Windows it crashed every time. I switched to posted events to try and get a working app.