QImage PlaylistModel::loadData(const ImageFile &f) { QImage img; QByteArray *data = prft.get(f.createKey()); if (data) { fprintf(stderr, "cache hit\n"); img.loadFromData(*data); } else { fprintf(stderr, "cache miss\n"); data = f.readData(); if (!data) return QImage(); img.loadFromData(*data); delete data; } if (img.format() != QImage::Format_ARGB32) { return img.convertToFormat(QImage::Format_ARGB32); } return img; }
void Prefetcher::Worker::run() { for (;;) { ImageFile *f = master->getTask(); QByteArray *data = f->readData(); master->setResult(f->createKey(), data); } }