增加vld检测memleak
							parent
							
								
									9a5d784283
								
							
						
					
					
						commit
						b28c28f425
					
				|  | @ -33,6 +33,13 @@ FORMS += \ | |||
| 
 | ||||
| LIBS += -lws2_32 | ||||
| 
 | ||||
| INCLUDEPATH += $$PWD/../../SDK/include | ||||
| 
 | ||||
| CONFIG(debug, debug|debug) { | ||||
| INCLUDEPATH += "D:/Visual Leak Detector/include" | ||||
| win32:LIBS += "D:/Visual Leak Detector/lib/Win64/vld.lib" | ||||
| } | ||||
| 
 | ||||
| TRANSLATIONS += \ | ||||
|     EmsShower_en_US.ts | ||||
| CONFIG += lrelease | ||||
|  |  | |||
|  | @ -1,3 +1,7 @@ | |||
| #ifdef _DEBUG | ||||
| #include <vld.h> | ||||
| #endif | ||||
| 
 | ||||
| #include "mainwindow.h" | ||||
| 
 | ||||
| #include <QApplication> | ||||
|  | @ -10,9 +14,11 @@ int main(int argc, char *argv[]) | |||
| 
 | ||||
|     QTranslator translator; | ||||
|     const QStringList uiLanguages = QLocale::system().uiLanguages(); | ||||
|     for (const QString &locale : uiLanguages) { | ||||
|     for (const QString &locale : uiLanguages) | ||||
|     { | ||||
|         const QString baseName = "EmsShower_" + QLocale(locale).name(); | ||||
|         if (translator.load(":/i18n/" + baseName)) { | ||||
|         if (translator.load(":/i18n/" + baseName)) | ||||
|         { | ||||
|             a.installTranslator(&translator); | ||||
|             break; | ||||
|         } | ||||
|  |  | |||
|  | @ -116,6 +116,12 @@ MainWindow::~MainWindow() | |||
|         ptr = nullptr; | ||||
|     } | ||||
|     m_SlaveData.clear(); | ||||
| 
 | ||||
|     if (m_pSettings!=nullptr) | ||||
|     { | ||||
|         delete m_pSettings; | ||||
|         m_pSettings = nullptr; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void MainWindow::getConfiguration(QString iniFilePath) | ||||
|  | @ -287,16 +293,16 @@ bool MainWindow::readRegister(int addr,int nb,uint16_t* dest) | |||
| 
 | ||||
|         delete []tab_reg; | ||||
| 
 | ||||
| 		DeviceData* pDevice = nullptr; | ||||
|         DeviceData* pDevice = nullptr; | ||||
| 
 | ||||
| 		if (pItem->start_address == TH08D_TEMPERATURE_EQUIPMENT_81_00_09 | ||||
| 			|| pItem->start_address == TH08D_TEMPERATURE_EQUIPMENT_81_09_06) | ||||
| 			pDevice = new TemperatureData(); | ||||
|         if (pItem->start_address == TH08D_TEMPERATURE_EQUIPMENT_81_00_09 | ||||
|                 || pItem->start_address == TH08D_TEMPERATURE_EQUIPMENT_81_09_06) | ||||
|             pDevice = new TemperatureData(); | ||||
| 
 | ||||
|         startAsyncProcess(registers,pItem->id,pItem->start_address, pItem->quantity, pDevice); | ||||
| 
 | ||||
|         if (pItem->start_address == TH08D_TEMPERATURE_EQUIPMENT_81_00_09 | ||||
|             || pItem->start_address == TH08D_TEMPERATURE_EQUIPMENT_81_09_06) | ||||
|                 || pItem->start_address == TH08D_TEMPERATURE_EQUIPMENT_81_09_06) | ||||
|         { | ||||
|             TemperatureData* pData = (TemperatureData*)pDevice; | ||||
|             assert(pData); | ||||
|  | @ -311,6 +317,7 @@ bool MainWindow::readRegister(int addr,int nb,uint16_t* dest) | |||
|         } | ||||
| 
 | ||||
|         qDebug() << "同步读取地址" << pItem->start_address; | ||||
|         delete pDevice; | ||||
|     } | ||||
|     return true; | ||||
| } | ||||
|  | @ -325,7 +332,7 @@ void MainWindow::startAsyncProcess(const QVector<uint16_t>& array,int slave_id,i | |||
| 
 | ||||
|     // 连接线程启动信号和槽函数
 | ||||
|     connect(this, &MainWindow::startProcessing, worker, &DecodeWorker::processArray); | ||||
| 	 | ||||
| 
 | ||||
|     // 工作完成后退出线程
 | ||||
|     connect(worker, &DecodeWorker::finished, thread, &QThread::quit); | ||||
|     connect(worker, &DecodeWorker::finished, worker, &DecodeWorker::deleteLater); | ||||
|  | @ -339,13 +346,13 @@ void MainWindow::startAsyncProcess(const QVector<uint16_t>& array,int slave_id,i | |||
| 
 | ||||
|     thread->start(); | ||||
| 
 | ||||
| 	QEventLoop loop; | ||||
| 	QObject::connect(worker, &DecodeWorker::finished, &loop, &QEventLoop::quit); | ||||
|     QEventLoop loop; | ||||
|     QObject::connect(worker, &DecodeWorker::finished, &loop, &QEventLoop::quit); | ||||
| 
 | ||||
| 	// 发射信号传递参数
 | ||||
| 	emit startProcessing(array, slave_id, start_addr, quantity, pDevice); | ||||
|     // 发射信号传递参数
 | ||||
|     emit startProcessing(array, slave_id, start_addr, quantity, pDevice); | ||||
| 
 | ||||
| 	// 阻塞,等待线程结束
 | ||||
|     // 阻塞,等待线程结束
 | ||||
|     loop.exec(); | ||||
| 
 | ||||
|     qDebug() << "同步读取完成"; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue