mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
resolved client side memory leak caused from gui
This commit is contained in:
parent
24b9402e52
commit
cdd18182a8
@ -4573,7 +4573,7 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
|||||||
int n,complete=OK;
|
int n,complete=OK;
|
||||||
int i,k,offsetX, offsetY, maxX, maxY; double dr;
|
int i,k,offsetX, offsetY, maxX, maxY; double dr;
|
||||||
int* retval=new int[nel];
|
int* retval=new int[nel];
|
||||||
int *retdet, *p=retval;
|
int *retdet = NULL, *p=retval;
|
||||||
string fullFName="";
|
string fullFName="";
|
||||||
string ext="";
|
string ext="";
|
||||||
|
|
||||||
@ -4585,22 +4585,21 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
|||||||
|
|
||||||
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
||||||
if (detectors[id]) {
|
if (detectors[id]) {
|
||||||
|
n=detectors[id]->getDataBytes();
|
||||||
retdet=detectors[id]->readFrameFromReceiver(fName,fIndex);
|
retdet=detectors[id]->readFrameFromReceiver(fName,fIndex);
|
||||||
if(detectors[id]->getErrorMask())
|
if(detectors[id]->getErrorMask())
|
||||||
setErrorMask(getErrorMask()|(1<<id));
|
setErrorMask(getErrorMask()|(1<<id));
|
||||||
if (retdet){
|
if (retdet){
|
||||||
if (fIndex==-1)
|
if (fIndex==-1){
|
||||||
complete = FAIL;
|
complete = FAIL;
|
||||||
else{
|
delete [] retdet;
|
||||||
|
}else{
|
||||||
n=detectors[id]->getDataBytes();
|
n=detectors[id]->getDataBytes();
|
||||||
if(getDetectorsType() == EIGER){
|
if(getDetectorsType() == EIGER){
|
||||||
//cout << "fname:"<<fName<<" findex:"<<fIndex<<endl;
|
//cout << "fname:"<<fName<<" findex:"<<fIndex<<endl;//cout<<"n:"<<n<<endl;//cout<<"maxchan:"<<detectors[id]->getMaxNumberOfChannels()<<" n:"<<n<<endl;
|
||||||
//cout<<"n:"<<n<<endl;
|
|
||||||
//cout<<"maxchan:"<<detectors[id]->getMaxNumberOfChannels()<<" n:"<<n<<endl;
|
|
||||||
dr = (double)n/detectors[id]->getMaxNumberOfChannels();
|
dr = (double)n/detectors[id]->getMaxNumberOfChannels();
|
||||||
//cout << "dr:"<<dr<<endl;
|
|
||||||
k=(int)(detectors[id]->getMaxNumberOfChannels(X)*dr);//bit mode
|
k=(int)(detectors[id]->getMaxNumberOfChannels(X)*dr);//bit mode
|
||||||
//cout << "k:"<<k<<endl;
|
//cout << "dr:"<<dr<<endl;//cout << "k:"<<k<<endl;
|
||||||
offsetY = (int)(((maxY - (thisMultiDetector->offsetY[id] + detectors[id]->getMaxNumberOfChannels(Y))) * maxX)*dr);//bit mode
|
offsetY = (int)(((maxY - (thisMultiDetector->offsetY[id] + detectors[id]->getMaxNumberOfChannels(Y))) * maxX)*dr);//bit mode
|
||||||
offsetX = (int)(thisMultiDetector->offsetX[id]*dr);
|
offsetX = (int)(thisMultiDetector->offsetX[id]*dr);
|
||||||
//cout << "offsetY"<<offsetY<< " offsetX:"<<offsetX<<endl;
|
//cout << "offsetY"<<offsetY<< " offsetX:"<<offsetX<<endl;
|
||||||
@ -4612,6 +4611,7 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
|||||||
memcpy(p,retdet,n);
|
memcpy(p,retdet,n);
|
||||||
p+=n/sizeof(int);
|
p+=n/sizeof(int);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] retdet;
|
delete [] retdet;
|
||||||
//concatenate filenames
|
//concatenate filenames
|
||||||
if(!fullFName.length()){
|
if(!fullFName.length()){
|
||||||
|
@ -9,7 +9,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
int dummyCallback(detectorData* d, int p,void*) {
|
||||||
|
cout << "got data " << p << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
class multiSlsDetectorClient {
|
class multiSlsDetectorClient {
|
||||||
|
|
||||||
@ -21,6 +24,7 @@ class multiSlsDetectorClient {
|
|||||||
if (argc==0 && action==slsDetectorDefs::READOUT_ACTION) { \
|
if (argc==0 && action==slsDetectorDefs::READOUT_ACTION) { \
|
||||||
if (myDetector==NULL) { \
|
if (myDetector==NULL) { \
|
||||||
myDetector=new multiSlsDetector(); \
|
myDetector=new multiSlsDetector(); \
|
||||||
|
//myDetector->registerDataCallback(&dummyCallback, NULL);
|
||||||
del=1; \
|
del=1; \
|
||||||
};
|
};
|
||||||
myCmd=new multiSlsDetectorCommand(myDetector); \
|
myCmd=new multiSlsDetectorCommand(myDetector); \
|
||||||
|
@ -6461,7 +6461,6 @@ int* slsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
|||||||
std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes << " " <<nel <<std::endl;
|
std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes << " " <<nel <<std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (connectData() == OK){
|
if (connectData() == OK){
|
||||||
//if(!thisDetector->stoppedFlag){
|
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
|
|
||||||
@ -6487,8 +6486,6 @@ int* slsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
dataSocket->Disconnect();
|
dataSocket->Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,10 +475,10 @@ void* postProcessing::processData(int delflag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fdata) {
|
if (fdata) {
|
||||||
cout << "delete fdata "<< endl;
|
//cout << "delete fdata "<< endl;
|
||||||
delete [] fdata;
|
delete [] fdata;
|
||||||
|
fdata = NULL;
|
||||||
cout << "delete done "<< endl;
|
//cout << "delete done "<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//receiver
|
//receiver
|
||||||
@ -535,6 +535,8 @@ void* postProcessing::processData(int delflag) {
|
|||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "currentfIndex:" << currentfIndex << endl;
|
cout << "currentfIndex:" << currentfIndex << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/** IF detector acquisition is done, let the acquire() thread know to finish up and force join thread */
|
/** IF detector acquisition is done, let the acquire() thread know to finish up and force join thread */
|
||||||
if(acquiringDone > 0){
|
if(acquiringDone > 0){
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
@ -579,6 +581,7 @@ void* postProcessing::processData(int delflag) {
|
|||||||
//get data
|
//get data
|
||||||
strcpy(currentfName,"");
|
strcpy(currentfName,"");
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
|
//int* receiverData = new int [getTotalNumberOfChannels()];
|
||||||
int* receiverData = readFrameFromReceiver(currentfName,currentfIndex);
|
int* receiverData = readFrameFromReceiver(currentfName,currentfIndex);
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
|
|
||||||
@ -599,7 +602,13 @@ void* postProcessing::processData(int delflag) {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
//not garbage frame
|
//not garbage frame
|
||||||
if (currentfIndex >= 0) {
|
if(currentfIndex < 0){
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<<endl;
|
||||||
|
#endif
|
||||||
|
if(receiverData)
|
||||||
|
delete [] receiverData;
|
||||||
|
}else{
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout<<"GOT data"<<endl;
|
cout<<"GOT data"<<endl;
|
||||||
#endif
|
#endif
|
||||||
@ -622,11 +631,6 @@ void* postProcessing::processData(int delflag) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
else{
|
|
||||||
cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<<endl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user