@@ -219,7 +219,7 @@ void MainWindow::slotProgConnectCompleted(int status)
219219 disconnect (prog, SIGNAL (connectCompleted (int )), this ,
220220 SLOT (slotProgConnectCompleted (int )));
221221
222- if (status)
222+ if (status < 0 )
223223 return ;
224224
225225 qInfo () << " Connected to programmer" ;
@@ -253,7 +253,7 @@ void MainWindow::slotProgReadDeviceIdCompleted(int status)
253253 disconnect (prog, SIGNAL (readChipIdCompleted (int )), this ,
254254 SLOT (slotProgReadDeviceIdCompleted (int )));
255255
256- if (status)
256+ if (status < 0 )
257257 return ;
258258
259259 idStr = tr (" 0x%1 0x%2 0x%3 0x%4 0x%5" )
@@ -325,7 +325,7 @@ void MainWindow::slotProgErase()
325325 prog->eraseChip (START_ADDRESS, eraseSize);
326326}
327327
328- void MainWindow::slotProgReadCompleted (int status )
328+ void MainWindow::slotProgReadCompleted (int readBytes )
329329{
330330 disconnect (prog, SIGNAL (readChipProgress (unsigned int )), this ,
331331 SLOT (slotProgReadProgress (unsigned int )));
@@ -334,15 +334,21 @@ void MainWindow::slotProgReadCompleted(int status)
334334
335335 setProgress (100 );
336336
337- if (status )
337+ if (readBytes < 0 )
338338 {
339339 buffer.clear ();
340340 return ;
341341 }
342342
343+ if (readBytes > buffer.size ())
344+ {
345+ qCritical () << " Read operation returned more than requested: " <<
346+ readBytes << " >" << buffer.size ();
347+ return ;
348+ }
349+
343350 qInfo () << " Data has been successfully read" ;
344- bufferTableModel.setBuffer (buffer.data (),
345- static_cast <uint32_t >(buffer.size ()));
351+ bufferTableModel.setBuffer (buffer.data (), readBytes);
346352}
347353
348354void MainWindow::slotProgReadProgress (unsigned int progress)
@@ -555,7 +561,7 @@ void MainWindow::slotProgDetectChipReadChipIdCompleted(int status)
555561 disconnect (prog, SIGNAL (readChipIdCompleted (int )), this ,
556562 SLOT (slotProgDetectChipReadChipIdCompleted (int )));
557563
558- if (status)
564+ if (status < 0 )
559565 return ;
560566
561567 idStr = tr (" 0x%1 0x%2 0x%3 0x%4 0x%5" )
@@ -593,7 +599,7 @@ void MainWindow::slotProgDetectChipConfCompleted(int status)
593599 disconnect (prog, SIGNAL (confChipCompleted (int )), this ,
594600 SLOT (slotProgDetectChipConfCompleted (int )));
595601
596- if (status)
602+ if (status < 0 )
597603 return ;
598604
599605 QTimer::singleShot (50 , this , &MainWindow::detectChipReadChipIdDelayed);
0 commit comments