qtQuick源代码中的loadImage函数

问题描述:

在qtQuick源代码中。有一个在功能的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())); 
    } 
} 

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