@@ -219,7 +219,7 @@ void MainWindow::slotProgConnectCompleted(int status)
219
219
disconnect (prog, SIGNAL (connectCompleted (int )), this ,
220
220
SLOT (slotProgConnectCompleted (int )));
221
221
222
- if (status)
222
+ if (status < 0 )
223
223
return ;
224
224
225
225
qInfo () << " Connected to programmer" ;
@@ -253,7 +253,7 @@ void MainWindow::slotProgReadDeviceIdCompleted(int status)
253
253
disconnect (prog, SIGNAL (readChipIdCompleted (int )), this ,
254
254
SLOT (slotProgReadDeviceIdCompleted (int )));
255
255
256
- if (status)
256
+ if (status < 0 )
257
257
return ;
258
258
259
259
idStr = tr (" 0x%1 0x%2 0x%3 0x%4 0x%5" )
@@ -325,7 +325,7 @@ void MainWindow::slotProgErase()
325
325
prog->eraseChip (START_ADDRESS, eraseSize);
326
326
}
327
327
328
- void MainWindow::slotProgReadCompleted (int status )
328
+ void MainWindow::slotProgReadCompleted (int readBytes )
329
329
{
330
330
disconnect (prog, SIGNAL (readChipProgress (unsigned int )), this ,
331
331
SLOT (slotProgReadProgress (unsigned int )));
@@ -334,15 +334,21 @@ void MainWindow::slotProgReadCompleted(int status)
334
334
335
335
setProgress (100 );
336
336
337
- if (status )
337
+ if (readBytes < 0 )
338
338
{
339
339
buffer.clear ();
340
340
return ;
341
341
}
342
342
343
+ if (readBytes > buffer.size ())
344
+ {
345
+ qCritical () << " Read operation returned more than requested: " <<
346
+ readBytes << " >" << buffer.size ();
347
+ return ;
348
+ }
349
+
343
350
qInfo () << " Data has been successfully read" ;
344
- bufferTableModel.setBuffer (buffer.data (),
345
- static_cast <uint32_t >(buffer.size ()));
351
+ bufferTableModel.setBuffer (buffer.data (), readBytes);
346
352
}
347
353
348
354
void MainWindow::slotProgReadProgress (unsigned int progress)
@@ -555,7 +561,7 @@ void MainWindow::slotProgDetectChipReadChipIdCompleted(int status)
555
561
disconnect (prog, SIGNAL (readChipIdCompleted (int )), this ,
556
562
SLOT (slotProgDetectChipReadChipIdCompleted (int )));
557
563
558
- if (status)
564
+ if (status < 0 )
559
565
return ;
560
566
561
567
idStr = tr (" 0x%1 0x%2 0x%3 0x%4 0x%5" )
@@ -593,7 +599,7 @@ void MainWindow::slotProgDetectChipConfCompleted(int status)
593
599
disconnect (prog, SIGNAL (confChipCompleted (int )), this ,
594
600
SLOT (slotProgDetectChipConfCompleted (int )));
595
601
596
- if (status)
602
+ if (status < 0 )
597
603
return ;
598
604
599
605
QTimer::singleShot (50 , this , &MainWindow::detectChipReadChipIdDelayed);
0 commit comments