can I assign another object after using deleteLater(); funcation?



  • is it fine? if i will assign new object to currentDataFile pointer. once I call deleteLater() for old object with help of currentDataFile.

    private member of class

    QFile* currentDataFile;
    QString currentDataFilePath;
    

    method of class

    void DataHandle::createNewDataFile(uint16_t nodeNum, const ExperimentSummaryInfo_t &expInfo) {
    	
    	if (!currentDataFile) {
    		
    		createNewFilePath(nodeNum, expInfo);
    		currentDataFile->flush();
    		currentDataFile->close();
    		currentDataFile->deleteLater();   
    	}
    
    	currentDataFile = new QFile(currentDataFilePath);
    	
    	if (!currentDataFile->open(QIODevice::WriteOnly)) {
    		currentDataFile->close();
    		currentDataFile->deleteLater();
    	}
    
    	return;
    }
    


  • @Yash001

    Yes. deleteLater is some sort of a member function of the object. You use only the pointer to start it.



  • @koahnig thank you.