【发布时间】:2017-10-17 15:58:16
【问题描述】:
在 qtQuick 源中。函数loadImage中有一行代码:
QQuickPixmap* pix = new QQuickPixmap();
如果我在canvas上尽量调用这个函数。操作系统分配给这个应用程序的内存会被填满,导致图片失效。请问有没有问题这个源代码?
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()));
}
}
【问题讨论】:
标签: c++ qt canvas qml qtquick2