@@ -44,7 +44,7 @@ void MainWindow::resetBufTable()
44
44
{
45
45
bufferTableModel.setBuffer (nullptr , 0 );
46
46
bufferSize = 0 ;
47
- delete buffer;
47
+ delete [] buffer;
48
48
}
49
49
50
50
MainWindow::MainWindow (QWidget *parent) : QMainWindow(parent),
@@ -89,7 +89,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
89
89
90
90
MainWindow::~MainWindow ()
91
91
{
92
- delete buffer;
92
+ delete [] buffer;
93
93
Logger::putInstance ();
94
94
delete ui;
95
95
}
@@ -276,7 +276,7 @@ void MainWindow::slotProgReadCompleted(int status)
276
276
277
277
if (status)
278
278
{
279
- delete buffer;
279
+ delete [] buffer;
280
280
return ;
281
281
}
282
282
@@ -288,10 +288,13 @@ void MainWindow::slotProgRead()
288
288
{
289
289
int index = ui->chipSelectComboBox ->currentIndex ();
290
290
ChipInfo *chipInfo = chipDb.chipInfoGetById (CHIP_INDEX2ID (index));
291
- uint32_t readSize = chipInfo->params [CHIP_PARAM_BLOCK_SIZE ];
291
+ uint32_t readSize = chipInfo->params [CHIP_PARAM_SIZE ];
292
292
293
- connect (prog, SIGNAL (readChipCompleted (int )), this ,
294
- SLOT (slotProgReadCompleted (int )));
293
+ if (!readSize)
294
+ {
295
+ qCritical () << " Chip size is not set" ;
296
+ return ;
297
+ }
295
298
296
299
resetBufTable ();
297
300
buffer = new (std::nothrow) uint8_t [readSize];
@@ -301,6 +304,9 @@ void MainWindow::slotProgRead()
301
304
return ;
302
305
}
303
306
307
+ connect (prog, SIGNAL (readChipCompleted (int )), this ,
308
+ SLOT (slotProgReadCompleted (int )));
309
+
304
310
prog->readChip (buffer, START_ADDRESS, readSize, true );
305
311
}
306
312
0 commit comments