QtConcurrentRun calls non-qt function
-
Hi,
QtConcurrentRun doesn't need your function to be Qt specific. Can you share the code of that function ?
-
[quote author="SGaist" date="1424711613"]Hi,
QtConcurrentRun doesn't need your function to be Qt specific. Can you share the code of that function ?[/quote]
Here is QtConcurrentRun function.
_brc is an object in non-qt library.
Usually crash(show disassembler view) after line 5.@void Spectrometer::doScanning()
{
if(_isFunctional==false) return; // disable operation if not functionalint result = _brc->startAcquiring(); //emit dataAcquisitionFinished(); // tell manager this data has been acquired. quint16 dataBuffer[SpectrometerData::PIXEL_NUM]; if(result == 1){ result = _brc->getYData(dataBuffer); } else{ // TODO:add error message box return; } _data_ptr.data()->updateUid(); // make new id to avoid duplication. //for flipped Spectrometer for(int i=0;i<SpectrometerData::PIXEL_NUM;i++){ auto y = dataBuffer[SpectrometerData::PIXEL_NUM-i-1]; _data_ptr.data()->updateY(i,y); } _isWorking=false; qDebug() << "Scan Finished"; emit scanFinished();
}@
@bool BRC::startAcquiring(){
char cmd[]="E\r\n";
int cmdLength = strlen(cmd);
if (write(_fd, cmd, cmdLength) < cmdLength){
return false;
}
return (wait("DR",cmdLength+7, _timeout));
}@ -
You are trying to write on the same file descriptor from several thread at once ?
-
Can you also show your call to QtConcurrentRun ?
-
Device manager contains two spectrometers,
@bool DeviceManager::scan()
{
_meter0->scan(); // scan in parallel
_meter1->scan(); // scan in parallel
return true;
}@
@bool Spectrometer::scan()
{
_progress = 0;
emit reportProgress(_progress);
// this will run parallel
QtConcurrent::run(this,&Spectrometer::doScanning);
_isWorking=true;
return true;
}@ -
Then are you sure that _brc is properly allocated ? That both are no trying to access the same resources at the same time ?
-
_brc is a pointer in Spectrometer class.
and I use new BRC() in Spectrometer's constructor.
Works most of time.and during my app starts up, each _brc did communicate with their corresponding hardware successfully.
Is it possible to allocate differently with same code but different runs?
-
What does the backtrace of a crash tell you ?
-
Are you running a debug build ?
-
Ok, then what does the debugger tell you ?