2017-10-17 8 views
-2

In qtQuick Source. 함수 loadImage에서 한 줄의 코드가있다 :qtQuick 소스 코드의 loadImage 함수

QQuickPixmap* pix = new QQuickPixmap(); 

나는 사진의 원인이됩니다 채워집니다이 응용 프로그램에 대한 운영 체제에 의해 할당 된 canvas.The 메모리에 최대한이 함수를 호출하는 경우 이 소스 코드에 문제가 있는지 묻고 싶습니다.

void QQuickCanvasItem::loadImage(const QUrl& url) 
{ 

    Q_D(QQuickCanvasItem); 
    QUrl fullPathUrl = d->baseUrl.resolved(url); 
    if (!d->pixmaps.contains(fullPathUrl)) { 
     QQuickPixmap* pix = new QQuickPixmap(); 
     QQmlRefPointer<QQuickCanvasPixmap> canvasPix; 
     canvasPix.adopt(new QQuickCanvasPixmap(pix)); 
     d->pixmaps.insert(fullPathUrl, canvasPix); 

     pix->load(qmlEngine(this) 
       , fullPathUrl 
       , QQuickPixmap::Cache | QQuickPixmap::Asynchronous); 
     if (pix->isLoading()) 
      pix->connectFinished(this, SIGNAL(imageLoaded())); 
    } 
} 

답변

-3
void QQuickCanvasItem::loadImage(const QUrl& url) 
{ 

    Q_D(QQuickCanvasItem); 
    QUrl fullPathUrl = d->baseUrl.resolved(url); 
    if (!d->pixmaps.contains(fullPathUrl)) { 
     QQuickPixmap* pix = new QQuickPixmap(); 
     QQmlRefPointer<QQuickCanvasPixmap> canvasPix; 
     canvasPix.adopt(new QQuickCanvasPixmap(pix)); 
     d->pixmaps.insert(fullPathUrl, canvasPix); 

     pix->load(qmlEngine(this) 
       , fullPathUrl 
       , QQuickPixmap::Cache | QQuickPixmap::Asynchronous); 
     if (pix->isLoading()) 
      pix->connectFinished(this, SIGNAL(imageLoaded())); 
    } 
}