[Qt-interest] Fwd: QCache accessing problem
Nathan Carter
nathancarter5 at gmail.com
Fri Jun 5 20:49:19 CEST 2009
> void Widget::getimage(QString string,QPixmap image)
> {
> if(!image.isNull())
> {
> if(!imageCache.contains(string))
> {
> qDebug() << "image got";
> QString yu = "yuvaraj";
> imageCache.insert(string,&image);
> qDebug() << "Hash Table size:" << imageCache.size();
> }
> }
> }
Is it possible that you're inserting &image into the cache, but the
caller of this has image allocated on the stack, and thus destroys it
shortly after calling getImage()? Just guessing, based on the fact
that you're passing in the QPixmap by value.
Nathan
More information about the Qt-interest-old
mailing list