Hi

I am making a scanner such as this
http://spritesmods.com/?art=mouseeye

from the device, everything is ready. But when i tray to print this on QGraphicsView I have a memory leak...

Qt Code:
  1. void MainWindow::parseFrame (QByteArray DATA){
  2.  
  3.  
  4. bool frameOK = true;
  5. QList <QByteArray> line = DATA.split('\n');
  6.  
  7. //DATA structure
  8. //
  9. //BO:
  10. //DE: 2bits x movement, y movement
  11. //SQ: 1bit Surface Quality
  12. //MI: 1bit
  13. //MA: 1bit
  14. //FR: 324bits ( SOF | Data_Valid | PD5 | PD4 | PD3 | PD2 | PD1 | PD0 ) where PDx intensity of pixel in gray scale
  15. //EO:
  16.  
  17.  
  18. for (int w = 0 ; w < line.size() ; w++)
  19. {
  20. if ( line.at(w).startsWith("FR:") && frameOK ) //Jeżeli dane są ramką
  21. {
  22. QList <QByteArray> frame = line.at(w).split(':');
  23.  
  24. if ( (frame.at(1).size() < 324) || (frame.at(1).size()>324 ))
  25. {
  26. qDebug()<<"Frame damaged :"<<frame.at(1).size();
  27. ramkaOK = false;
  28. }//IF
  29. else
  30. {
  31. scene->clear(); // !!!!!!!!
  32. quint8 col;
  33. quint16 pixelIndex;
  34. for( pixelIndex = 0 ; pixelIndex < 18*18 ; ){
  35. col = (quint8)(frame.at(1)[pixelIndex] << 2 );
  36. color->setRgb(col,col,col);
  37. brush->setColor(*color);
  38. //That section works well
  39. scene->addRect( ((quint8)(pixelIndex/18))*7, //X
  40. (17 - (pixelIndex%18))*7, //Y
  41. 7,7,*pen,*brush );
  42. //This section will leak memory, because I add data instead of overwriting
  43. bigScene->addRect(((quint8)(pixelIndex/18))+X, //x + DELTA X
  44. (17 - (pixelIndex%18))+Y, //y + DELTA Y
  45. 1,1,*pen,*brush );
  46. }
  47. } //ELSE Frame OK
  48. }//FRAME
  49. if ( line.at(w).startsWith("DE:") ) //DELTA
  50. {
  51. QList <QByteArray> delta = line.at(w).split(':');
  52.  
  53. dx = delta.at(1)[0];
  54. dy = delta.at(1)[1];
  55. if ( ((dx > -127) && ( dx < 128 )) &&
  56. ((dx > -127) && ( dx < 128 )) ){
  57. X+=dx;
  58. Y-=dy;
  59. }
  60. else
  61. {
  62. qDebug()<< "DX DY damaged" ;
  63. frameOK = false;
  64. }
  65.  
  66. } //IF DELTA
  67.  
  68. //ui->currentView is a QGraphicView
  69. ui->currentView->setScene(scene);
  70. // ui->bigView->setScene(bigScene); //This causes a memory leak
  71. ui->sourceQuality->replot();
  72. ui->minMaxVal->replot();
  73.  
  74. }
To copy to clipboard, switch view to plain text mode 

My question is, how can I draw the big picture?