[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [soprano/2.8] soprano: Revert "ErrorCache: Use QThreadStorage instead of a QHash with a mutex"
From: Vishesh Handa <me () vhanda ! in>
Date: 2012-08-02 6:14:12
Message-ID: 20120802061412.8A522A6094 () git ! kde ! org
[Download RAW message or body]
Git commit c4a0a950d05c7005879e2a086d3911ce28cef1cd by Vishesh Handa.
Committed on 01/08/2012 at 19:53.
Pushed by vhanda into branch '2.8'.
Revert "ErrorCache: Use QThreadStorage instead of a QHash with a mutex"
This reverts commit f4d2b9898ff958db1c69ac55fb21677bb6075e24.
QThreadStorage are only meant to be used for static variables. This is
not their intended use case. We get warning every time a QThreadStorage
is deleted before its thread is deleted. The ErrorCache is used heavily
in Soprano for small objects such as iterators, and thus we get these
warnings a lot.
M +9 -6 soprano/error.cpp
http://commits.kde.org/soprano/c4a0a950d05c7005879e2a086d3911ce28cef1cd
diff --git a/soprano/error.cpp b/soprano/error.cpp
index 12eb454..bff34dd 100644
--- a/soprano/error.cpp
+++ b/soprano/error.cpp
@@ -28,7 +28,6 @@
#include <QtCore/QMutex>
#include <QtCore/QMutexLocker>
#include <QtCore/QThread>
-#include <QtCore/QThreadStorage>
namespace Soprano {
@@ -187,7 +186,8 @@ Soprano::Error::Locator Soprano::Error::ParserError::locator() \
const class Soprano::Error::ErrorCache::Private
{
public:
- QThreadStorage<Error> errorStorage;
+ QHash<QThread*, Error> errorMap;
+ QMutex errorMapMutex;
};
@@ -205,7 +205,8 @@ Soprano::Error::ErrorCache::~ErrorCache()
Soprano::Error::Error Soprano::Error::ErrorCache::lastError() const
{
- return d->errorStorage.localData();
+ QMutexLocker locker( &d->errorMapMutex );
+ return d->errorMap.value( QThread::currentThread() );
}
@@ -217,8 +218,8 @@ void Soprano::Error::ErrorCache::setError( const Error& error ) \
const
? QString( "%1(%2)" ).arg( app->applicationFilePath() ).arg( \
app->applicationPid() ) : QString() )
<< "Soprano:" << error;
- Q_UNUSED( app ); // when compiled with release mode
- d->errorStorage.setLocalData( error );
+ QMutexLocker locker( &d->errorMapMutex );
+ d->errorMap[QThread::currentThread()] = error;
}
else {
clearError();
@@ -234,7 +235,9 @@ void Soprano::Error::ErrorCache::setError( const QString& \
errorMessage, int code
void Soprano::Error::ErrorCache::clearError() const
{
- d->errorStorage.setLocalData( Error() );
+ QMutexLocker locker( &d->errorMapMutex );
+ if ( !d->errorMap.isEmpty() )
+ d->errorMap[QThread::currentThread()] = Error();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic