summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-06-18 11:38:10 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-06-18 11:39:47 (GMT)
commit747c7a9a060267dee9622c96bf0e2a54147dacfa (patch)
tree9e787664dc5cf21d0078649dfa99626c98f8e630 /src/gui/itemviews
parent88130cb56b0b1b7332430d6045946635ca1c8c75 (diff)
downloadQt-747c7a9a060267dee9622c96bf0e2a54147dacfa.zip
Qt-747c7a9a060267dee9622c96bf0e2a54147dacfa.tar.gz
Qt-747c7a9a060267dee9622c96bf0e2a54147dacfa.tar.bz2
QItemEditorFactory: made sure the ownership is taken on the
QItemEditorCreator The creators were not deleted i nthe destructor of QItemEditorFactory and they could not be safely used for more than one type. Task-number: 228255 Reviewed-by: jasplin
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qitemeditorfactory.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gui/itemviews/qitemeditorfactory.cpp b/src/gui/itemviews/qitemeditorfactory.cpp
index c576e40..480a472 100644
--- a/src/gui/itemviews/qitemeditorfactory.cpp
+++ b/src/gui/itemviews/qitemeditorfactory.cpp
@@ -158,6 +158,10 @@ QByteArray QItemEditorFactory::valuePropertyName(QVariant::Type type) const
*/
QItemEditorFactory::~QItemEditorFactory()
{
+ //we make sure we delete all the QItemEditorCreatorBase
+ //this has to be done only once, hence the QSet
+ QSet<QItemEditorCreatorBase*> set = creatorMap.values().toSet();
+ qDeleteAll(set);
}
/*!
@@ -170,8 +174,16 @@ QItemEditorFactory::~QItemEditorFactory()
*/
void QItemEditorFactory::registerEditor(QVariant::Type type, QItemEditorCreatorBase *creator)
{
- delete creatorMap.value(type, 0);
- creatorMap[type] = creator;
+ QHash<QVariant::Type, QItemEditorCreatorBase *>::iterator it = creatorMap.find(type);
+ if (it != creatorMap.end()) {
+ QItemEditorCreatorBase *oldCreator = it.value();
+ Q_ASSERT(oldCreator);
+ creatorMap.erase(it);
+ if (!creatorMap.values().contains(oldCreator))
+ delete oldCreator; // if it is no more in use we can delete it
+ }
+
+ creatorMap[type] = creator;
}
class QDefaultItemEditorFactory : public QItemEditorFactory