Well, it was leftover sort of. I had originally created one QImageReader, passed that pointer to all tiles, and used it to keep multiple threads for reading from the same file at once because I was getting some errors from libjpeg, libpng, etc. This made me think that was the issue.

Presently I get no errors, the image just doesnt load and look correct.

Well, it was leftover sort of. I had originally created one QImageReader, passed that pointer to all tiles, and used it to keep multiple threads for reading from the same file at once because I was getting some errors from libjpeg, libpng, etc. This made me think that was the issue.

Presently I get no errors, the image just doesnt load and look correct.

Here is the full code from my first try - passing a pointer to the reader into each tile:

Header:

Qt Code:
  1. class RasterTile : public Tile
  2. {
  3. public:
  4. RasterTile (QImageReader *reader, int nBlocksX, int nBlocksY, int xoffset, int yoffset, int nXBlockSize, int nYBlockSize);
  5.  
  6. protected:
  7. QImageReader *reader;
  8. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget);
  9. QImage LoadTilePixmap();
  10. private:
  11. mutable QMutex mutex;
  12. };
To copy to clipboard, switch view to plain text mode 

Cpp:

Qt Code:
  1. #include "rastertile.h"
  2.  
  3. RasterTile::RasterTile(QImageReader *reader, int nBlocksX, int nBlocksY, int xoffset, int yoffset, int nXBlockSize, int nYBlockSize)
  4. : Tile(nBlocksX, nBlocksY, xoffset, yoffset, nXBlockSize, nYBlockSize)
  5. {
  6. this->reader = reader;
  7. connect(&watcher,SIGNAL(finished()),this,SLOT(updateSceneSlot()));
  8. }
  9.  
  10.  
  11. void RasterTile::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
  12. {
  13. if(image.isNull())
  14. {
  15. TilePainter=painter;
  16. TileOption=option;
  17. TileWidget=widget;
  18. future = QtConcurrent::run(this, &RasterTile::LoadTilePixmap);
  19. watcher.setFuture(future);
  20.  
  21. }else
  22. {
  23. QRectF imageRect = image.rect();
  24. painter->drawImage(imageRect, image);
  25. }
  26.  
  27. }
  28.  
  29. QImage RasterTile::LoadTilePixmap()
  30. {
  31. QMutexLocker locker(&mutex);
  32. QImage img(nBlockXSize, nBlockYSize, QImage::Format_RGB32);
  33. QRect rect(tilePosX*nBlockXSize, tilePosY*nBlockYSize, nBlockXSize, nBlockYSize);
  34. reader->setClipRect(rect);
  35. reader->read(&img);
  36. return img;
  37.  
  38. }
To copy to clipboard, switch view to plain text mode 



How I am instantiating the classes:

Qt Code:
  1. for(int i =0; i < nXBlocks; i++)
  2. {
  3. for(int j = 0; j < nYBlocks; j++)
  4. {
  5. RasterTile *ipi = new RasterTile(reader,nXBlocks, nYBlocks, i, j, nXBlockSize, nYBlockSize);
  6.  
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 

After this try, is when i started trying to make the mutex private, and then also passing in just the file name so each Tile could create it's own reader.

"image" is a QImage that gets set to the img from "LoadTilePixmap()" and is set in the Tile::updateSceneSlot()