Home > Mobile >  Qt emit signal hint 0 xc0000005: while reading position 0 x00000024 access conflict. Excuse me, how
Qt emit signal hint 0 xc0000005: while reading position 0 x00000024 access conflict. Excuse me, how

Time:05-08

Write UDP receives the application, receive is a separate thread, and then when received after reaching a certain amount of data sent to another child thread execution process, here is my receiving thread code:
While (myUdpSocket - & gt; HasPendingDatagrams ())
{
QByteArray tempArray;
Quint64 size=myUdpSocket - & gt; PendingDatagramSize ();
TempArray. Resize (size);
MyUdpSocket - & gt; ReadDatagram (tempArray. Data (), tempArray. The size ());
If (tempArray!="End!" )//each frame data after the hair will send again "End!"
{
Num_recvData +=tempArray. The size ();//Num_recvData refers to a record number of bytes of data received
Array_recv. Append (tempArray);//array_recv QByteArray global variables,
Emit sig_recv_byteNum (Num_recvData);//receive bytes signal, through the signal is sent to the UI thread
If (array_recv. The size () & gt;=sizeof (recvData_struct))//when receiving data bytes up to par, send it to the processing threads to handle
{
Emit sig_recv_finish (array_recv);//send a frame receive complete signal
Array_recv. The clear ();
QDebug () & lt; & lt;" Recv_success!" ;
}
}
}
In the way emit sig_recv_finish (array_recv) here, interrupt the QMetaObject below: : activate (this, & amp; StaticMetaObject, 2, _a) this way, and an error 0 xc0000005: while reading position 0 x00000024 access conflict,
//SIGNAL 2
Void recvThread: : sig_recv_finish (QByteArray _t1)
{
Void * _a []={Q_NULLPTR, const_cast & lt; Void * & gt; (reinterpret_cast & lt; Const void * & gt; (& amp; _t1)};
QMetaObject: : activate (this, & amp; StaticMetaObject, 2, _a);
}

Looking for a long time just found a similar post, but it was useless,
Actually more than this a signal, the UI thread when I send a reset signal to the child thread is also one of the mistakes, so could you please tell me how do you solve this problem,

CodePudding user response:

Your header file also have no, who knows what this signal and cao function defined by you, said again, since is a global object, you are not necessary when parameters,

CodePudding user response:

Wrong, is not a global variable, just declared in the header file, I'm sorry, I am a novice, just learned before long,
As for signal and slot function, signal is the following, the signal does not need to define it, as for the tank I because it is the signal error function, so I thought with groove function it doesn't matter
The connection function in the UI thread:
The connect (myrecvThread, & amp; RecvThread: : sig_recv_finish, myhandleThread, & amp; HandleThread: : the handleData);//the first parameter when receiving threads variables, the third number processing threads variable
Signal:
Signals:
Void sig_recv_finish (QByteArray);
Slot functions:
Void handleThread: : the handleData (QByteArray recv_data)
{
QByteArray array=recv_data;
MSG=(recvData_struct *) array. The data ();//will receive the data into a structure
If ((MSG - & gt; M_frame_head [0]==QString (" 55 "). ToInt (& amp; Ok, 16)) & amp; & (MSG - & gt; M_frame_end [0]==QString (" 59 "). ToInt (& amp; Ok, 16)))//the recognition of simple frame head frame end
{
Is among a variety of processing, if you need to post it, I'll mainly I think didn't enter the tank from processing function,,
}
}
Is one more thing, I preach the image, and each time a frame can be received, can also be displayed, but by the second frame will be jumped the program and then prompt the error signal,

CodePudding user response:

Estimates is the program logic design has a problem
  •  Tags:  
  • Qt
  • Related