I have this global variable. void * userInterface; and this line in main.cpp _beginthread( ReceiveThread, 0, NULL); and

ReceiveThread

void ReceiveThread( void* Param )
{
	...........
	QString str;
	rovkonInterface *w=((rovkonInterface *)userInterface);
	w->ui.systemStatusText->insertPlainText("abc");
        ........

and I get runtime error:
ASSERT:"qApp && qApp->thread()==currentQThread" in file ....

and I tested same code snippet in normal functions and it worked properly. Also I used other global variable also without a problem, but when insert the line: w->ui.systemStatusText->insertPlainText("abc"); I am getting runtime error.

What can be the problem?
Thanks.

Is the global variable shared between threads?

The assert seems to be checking that some property is equal to the current thread.
The assert is triggered when this is NO LONGER TRUE

My deduction is that you have several threads munging the same data, and sooner or later, boom.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.