summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-11-04 16:23:04 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-11-22 14:09:07 (GMT)
commit5e13c65b7083ba6a28820a82f2fa19ca8c1569b0 (patch)
treebb5f514be56ea2cd6f26641230e02c88ff70c405 /doc
parented8f3b6c98f1b305f0d183bc70c5f810a9c45ef2 (diff)
downloadQt-5e13c65b7083ba6a28820a82f2fa19ca8c1569b0.zip
Qt-5e13c65b7083ba6a28820a82f2fa19ca8c1569b0.tar.gz
Qt-5e13c65b7083ba6a28820a82f2fa19ca8c1569b0.tar.bz2
Make QThreadStorage supports value type and not only pointers.
Handling value type is much more natural than handling pointer. It was not possible to use normal type in QThreadStorage previously (probably because some compiler would not support it?) This should ease a lot the use of QThreadStorage and make it more intuitive. The only problem was the QThreadStorage::deleteData() that would not compile for nonn-pointer. This is now fixed Also updated the documentation. Reviewed-by: Joao Reviewed-by: Brad Task-number: QTBUG-15033
Diffstat (limited to 'doc')
-rw-r--r--doc/src/snippets/threads/threads.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/doc/src/snippets/threads/threads.cpp b/doc/src/snippets/threads/threads.cpp
index d8d1270..d16c398 100644
--- a/doc/src/snippets/threads/threads.cpp
+++ b/doc/src/snippets/threads/threads.cpp
@@ -93,15 +93,12 @@ private:
typedef int SomeClass;
//! [7]
-QThreadStorage<QCache<QString, SomeClass> *> caches;
+QThreadStorage<QCache<QString, SomeClass> > caches;
void cacheObject(const QString &key, SomeClass *object)
//! [7] //! [8]
{
- if (!caches.hasLocalData())
- caches.setLocalData(new QCache<QString, SomeClass>);
-
- caches.localData()->insert(key, object);
+ caches.localData().insert(key, object);
}
void removeFromCache(const QString &key)
@@ -110,7 +107,7 @@ void removeFromCache(const QString &key)
if (!caches.hasLocalData())
return;
- caches.localData()->remove(key);
+ caches.localData().remove(key);
}
//! [9]