Hello,
I have a program with a thread that continuously check the parallel port for incoming data and after receiving a complete block of data it sends it to the main application. The data is send as an interger array, whose size depends on the data received.
The problem I have is that the thread sends the data as an event (using Qt customEvent class). So if I send the address of the array, there is always a possibilty the thread will erase it with new data from the port BEFORE the application process it. How can I pass a complete copy of the array and not only the address of the first cell (The size of the array is non constant, the first cell contains the size)
Right now here is the code I use :
if (DataReceived)
MyCustomEvent->setData(intArray)
postEvent(mainApp, MyCustomEvent)
end if
...
//As soon as new data is received
delete intArray
intArray = new int[Whatever size the new data is]
If you need more info tell me
Thanks.
I have a program with a thread that continuously check the parallel port for incoming data and after receiving a complete block of data it sends it to the main application. The data is send as an interger array, whose size depends on the data received.
The problem I have is that the thread sends the data as an event (using Qt customEvent class). So if I send the address of the array, there is always a possibilty the thread will erase it with new data from the port BEFORE the application process it. How can I pass a complete copy of the array and not only the address of the first cell (The size of the array is non constant, the first cell contains the size)
Right now here is the code I use :
if (DataReceived)
MyCustomEvent->setData(intArray)
postEvent(mainApp, MyCustomEvent)
end if
...
//As soon as new data is received
delete intArray
intArray = new int[Whatever size the new data is]
If you need more info tell me
Thanks.