@@ -237,11 +237,17 @@ void MainWindow::slotProgRead()
237
237
std::placeholders::_1), readBuf, START_ADDRESS, readBufSize);
238
238
}
239
239
240
+ void MainWindow::writeChipCb (int status)
241
+ {
242
+ if (!status)
243
+ qInfo () << " Data has been successfully written" ;
244
+ delete writeBuf;
245
+ }
246
+
240
247
void MainWindow::slotProgWrite ()
241
248
{
242
249
bool convIsOk;
243
250
QStringList sl;
244
- std::unique_ptr< uint8_t [] > buf;
245
251
uint32_t bufSize, bufIter = 0 ;
246
252
uint32_t rowCount = ui->bufferTableWidget ->rowCount () - HEADER_ROW_NUM;
247
253
@@ -252,8 +258,8 @@ void MainWindow::slotProgWrite()
252
258
}
253
259
254
260
bufSize = rowCount * ROW_DATA_SIZE;
255
- buf = std::unique_ptr< uint8_t [] >( new (std::nothrow) uint8_t [bufSize]) ;
256
- if (!buf. get () )
261
+ writeBuf = new (std::nothrow) uint8_t [bufSize];
262
+ if (!writeBuf )
257
263
{
258
264
qCritical () << " Failed to allocate memory for write buffer" ;
259
265
return ;
@@ -266,7 +272,7 @@ void MainWindow::slotProgWrite()
266
272
267
273
for (int j = 0 ; j < sl.size (); j++)
268
274
{
269
- buf [bufIter++] = sl.at (j).toUInt (&convIsOk, 16 );
275
+ writeBuf [bufIter++] = sl.at (j).toUInt (&convIsOk, 16 );
270
276
if (!convIsOk)
271
277
{
272
278
qCritical () << " Failed to convert row item to byte" ;
@@ -275,8 +281,8 @@ void MainWindow::slotProgWrite()
275
281
}
276
282
}
277
283
278
- if (! prog->writeChip (buf. get (), START_ADDRESS, bufIter))
279
- qInfo () << " Data has been successfully written " ;
284
+ prog->writeChip (std::bind (&MainWindow::writeChipCb, this ,
285
+ std::placeholders::_1), writeBuf, START_ADDRESS, bufIter) ;
280
286
}
281
287
282
288
void MainWindow::selectChipCb ()
0 commit comments