r14705 by fschmid - Made the picbrowser a bit more stable.

scribus-commit scribus-commit at lists.scribus.net
Sat Feb 13 11:20:50 CET 2010


Revision: 14705
Author: fschmid
Date: 2010-02-13T10:17:24.082541Z
Commit message: Made the picbrowser a bit more stable.

Changeset: 
M  /trunk/Scribus/scribus/plugins/picbrowser/loadimage.cpp
M  /trunk/Scribus/scribus/plugins/picbrowser/previewimage.cpp
M  /trunk/Scribus/scribus/plugins/picbrowser/loadimage.h

Diffs:
Index: scribus/plugins/picbrowser/loadimage.cpp
===================================================================
--- scribus/plugins/picbrowser/loadimage.cpp	(revision 14704)
+++ scribus/plugins/picbrowser/loadimage.cpp	(revision 14705)
@@ -30,38 +30,43 @@
 
 loadImagesThread::loadImagesThread ( PictureBrowser *parent, PreviewImagesModel *parentModel )
 {
+	mutex.lock();
 	pictureBrowser = parent;
 	pModel = parentModel;
+	mutex.unlock();
 }
 
 
 void loadImagesThread::run()
 {
-	loadImagesThreadInstance help;
+//	loadImagesThreadInstance help;
 
-	help.pictureBrowser = pictureBrowser;
-	help.pModel = pModel;
+//	help.pictureBrowser = pictureBrowser;
+//	help.pModel = pModel;
 
 //register types for slots and signals
 	qRegisterMetaType<previewImage *> ( "previewImage*" );
 	qRegisterMetaType<ImageInformation *> ( "ImageInformation*" );
 	qRegisterMetaType<QImage> ( "QImage" );
 
-	connect(&help, SIGNAL(imageLoaded(int, const QImage, ImageInformation*, int) ), pModel, SLOT(processLoadedImage(int, const QImage, ImageInformation*, int)), Qt::QueuedConnection);
-	connect(&help, SIGNAL(imageLoadError(int, int, int)), pModel, SLOT(processImageLoadError(int, int, int)), Qt::QueuedConnection);
-	connect(pictureBrowser, SIGNAL(loadImageJob(int, QString, int, int)), &help, SLOT(processLoadImageJob(int, QString, int, int)), Qt::QueuedConnection);
+//	connect(&help, SIGNAL(imageLoaded(int, const QImage, ImageInformation*, int) ), pModel, SLOT(processLoadedImage(int, const QImage, ImageInformation*, int)), Qt::QueuedConnection);
+//	connect(&help, SIGNAL(imageLoadError(int, int, int)), pModel, SLOT(processImageLoadError(int, int, int)), Qt::QueuedConnection);
+//	connect(pictureBrowser, SIGNAL(loadImageJob(int, QString, int, int)), &help, SLOT(processLoadImageJob(int, QString, int, int)), Qt::QueuedConnection);
 
+	connect(this, SIGNAL(imageLoaded(int, const QImage, ImageInformation*, int) ), pModel, SLOT(processLoadedImage(int, const QImage, ImageInformation*, int)), Qt::QueuedConnection);
+	connect(this, SIGNAL(imageLoadError(int, int, int)), pModel, SLOT(processImageLoadError(int, int, int)), Qt::QueuedConnection);
+	connect(pictureBrowser, SIGNAL(loadImageJob(int, QString, int, int)), this, SLOT(processLoadImageJob(int, QString, int, int)), Qt::QueuedConnection);
 	exec();
 }
 
-
+/*
 loadImagesThreadInstance::loadImagesThreadInstance()
 {
 }
-
-void loadImagesThreadInstance::processLoadImageJob ( int row, QString path, int size, int tpId )
+*/
+void loadImagesThread::processLoadImageJob ( int row, QString path, int size, int tpId )
 {
-	ScImageCacheManager & icm = ScImageCacheManager::instance();
+	ScImageCacheManager &icm = ScImageCacheManager::instance();
 	bool cacheEnabled = icm.enabled();
 	icm.setEnabled(false);
 	//check if list of files has changed and this job is obsolete
Index: scribus/plugins/picbrowser/previewimage.cpp
===================================================================
--- scribus/plugins/picbrowser/previewimage.cpp	(revision 14704)
+++ scribus/plugins/picbrowser/previewimage.cpp	(revision 14705)
@@ -481,7 +481,7 @@
 	if ( role == Qt::DecorationRole )
 	{
 		pictureBrowser->currentRow = row;
-
+/*
 		//preload icons before and after current icon
 		if ( ( row - pictureBrowser->previewIconsVisible ) >= 0 )
 		{
@@ -504,7 +504,7 @@
 				pictureBrowser->callLoadImageThread ( row + pictureBrowser->previewIconsVisible, pId );
 			}
 		}
-
+*/
 		if ( !tmpImage->previewIconCreated )
 		{
 			if ( !tmpImage->previewImageLoading )
Index: scribus/plugins/picbrowser/loadimage.h
===================================================================
--- scribus/plugins/picbrowser/loadimage.h	(revision 14704)
+++ scribus/plugins/picbrowser/loadimage.h	(revision 14705)
@@ -24,6 +24,7 @@
 #include <QObject>
 #include <QString>
 #include <QThread>
+#include <QMutex>
 
 class ImageInformation;
 class PictureBrowser;
@@ -42,11 +43,12 @@
 		void run();
 
 	private:
+		QMutex mutex;
 		//contains a pointer to the calling PictureBrowser object
 		PictureBrowser *pictureBrowser;
 		//contains a pointer to the related PreviewImagesModel
 		PreviewImagesModel *pModel;
-};
+/*};
 
 
 //a helper class to get the signals/slots executed in the right thread
@@ -61,7 +63,7 @@
 		PictureBrowser *pictureBrowser;
 		//contains a pointer to the related PreviewImagesModel
 		PreviewImagesModel *pModel;
-
+*/
 	signals:
 		//emitted when image was loaded
 		//parameters:




More information about the scribus-commit mailing list