2017-10-17 7 views
-2

En qtQuick Source. Il y a une ligne de code dans la fonction loadImage:Fonction loadImage dans le code source qtQuick

QQuickPixmap* pix = new QQuickPixmap(); 

Si j'appelle cette fonction autant que possible sur la mémoire canvas.The allouée par le système d'exploitation de cette application sera remplie, ce qui provoquera l'image échouer.J'aimerais demander s'il y a un problème avec ce code source?

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())); 
    } 
} 

Répondre

-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())); 
    } 
}