some pointers deleted equalled to null

This commit is contained in:
Dhanya Maliakal 2015-03-05 15:30:21 +01:00
parent 848569b216
commit 71ad7ae2f0
2 changed files with 12 additions and 11 deletions

View File

@ -49,8 +49,8 @@ qDrawPlot::~qDrawPlot(){
plot1D_hists.clear(); plot1D_hists.clear();
if(lastImageArray) delete[] lastImageArray; lastImageArray=0; if(lastImageArray) delete[] lastImageArray; lastImageArray=0;
StartOrStopThread(0); StartOrStopThread(0);
delete myDet; delete myDet; myDet = 0;
for(int i=0;i<MAXCloneWindows;i++) if(winClone[i]) delete winClone[i]; for(int i=0;i<MAXCloneWindows;i++) if(winClone[i]) {delete winClone[i]; winClone[i] = NULL;}
} }
@ -1296,8 +1296,10 @@ void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D
void qDrawPlot::Clear1DPlot(){ void qDrawPlot::Clear1DPlot(){
for(QVector<SlsQtH1D*>::iterator h = plot1D_hists.begin(); h!=plot1D_hists.end();h++) for(QVector<SlsQtH1D*>::iterator h = plot1D_hists.begin(); h!=plot1D_hists.end();h++){
(*h)->Detach(plot1D); (*h)->Detach(plot1D);
//do not delete *h or h.
}
plotHistogram->detach(); plotHistogram->detach();
} }
@ -1719,8 +1721,7 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
//get trimbits //get trimbits
actualPixelsX = myDet->getTotalNumberOfChannels(slsDetectorDefs::X); actualPixelsX = myDet->getTotalNumberOfChannels(slsDetectorDefs::X);
if(histTrimbits) delete [] histTrimbits; if(histTrimbits) delete [] histTrimbits; histTrimbits = new double[actualPixelsX];
histTrimbits = new double[actualPixelsX];
ret = myDet->getChanRegs(histTrimbits,fromDetector); ret = myDet->getChanRegs(histTrimbits,fromDetector);
// cout << "got it!" << endl; // cout << "got it!" << endl;
if(!ret){ if(!ret){

View File

@ -197,7 +197,7 @@ void qTabActions::SetupWidgetWindow(){
//load positions //load positions
if(lblName[NumPositions]->isEnabled()){ if(lblName[NumPositions]->isEnabled()){
//delete existing positions //delete existing positions
if (positions) delete [] positions; if (positions) {delete [] positions; positions = NULL;}
//get number of positions //get number of positions
int numPos=myDet->getPositions(); int numPos=myDet->getPositions();
comboPos->setMaxCount(numPos); comboPos->setMaxCount(numPos);
@ -404,7 +404,7 @@ void qTabActions::SetPosition(){
} }
//delete existing positions //delete existing positions
if (positions) delete [] positions; if (positions) {delete [] positions; positions = NULL;}
positions=new double[comboPos->count()]; positions=new double[comboPos->count()];
//copying the list //copying the list
for(int i=0;i<comboPos->count();i++) for(int i=0;i<comboPos->count();i++)
@ -483,7 +483,7 @@ void qTabActions::Refresh(){
if(lblName[NumPositions]->isEnabled()){ if(lblName[NumPositions]->isEnabled()){
//delete existing positions //delete existing positions
if (positions) delete [] positions; if (positions) {delete [] positions; positions = NULL;}
//get number of positions //get number of positions
int numPos=myDet->getPositions(); int numPos=myDet->getPositions();
comboPos->setMaxCount(numPos); comboPos->setMaxCount(numPos);