[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kexi/kexidb
From: Jarosław Staniek <staniek () kde ! org>
Date: 2010-04-18 22:40:38
Message-ID: 20100418224038.2781DAC89E () svn ! kde ! org
[Download RAW message or body]
SVN commit 1116241 by staniek:
KexiDB
*fix possible crash when adding two or more new columns to a table at once
BUG:234194
*rename typedefs to use Const when needed
M +28 -9 alter.cpp
M +4 -2 alter.h
M +1 -1 drivermanager.cpp
--- trunk/koffice/kexi/kexidb/alter.cpp #1116240:1116241
@@ -54,6 +54,7 @@
AlterTableHandler::ActionBase::~ActionBase()
{
+ kDebug() << this;
}
AlterTableHandler::ChangeFieldPropertyAction& \
AlterTableHandler::ActionBase::toChangeFieldPropertyAction() @@ -101,6 +102,7 @@
AlterTableHandler::FieldActionBase::~FieldActionBase()
{
+ kDebug() << this;
}
//--------------------------------------------------------
@@ -204,6 +206,7 @@
AlterTableHandler::ChangeFieldPropertyAction::~ChangeFieldPropertyAction()
{
+ kDebug() << this;
}
void AlterTableHandler::ChangeFieldPropertyAction::updateAlteringRequirements()
@@ -263,11 +266,14 @@
static void debugActionDict(AlterTableHandler::ActionDict *dict, int fieldUID, bool \
simulate) {
QString fieldName;
- AlterTableHandler::ActionDictIterator it(dict->constBegin());
- if (it != dict->constEnd()) //retrieve field name from the 1st related action
+ AlterTableHandler::ActionDictConstIterator it(dict->constBegin());
+ if (it != dict->constEnd() && \
dynamic_cast<AlterTableHandler::FieldActionBase*>(it.value())) { + //retrieve \
field name from the 1st related action
fieldName = \
dynamic_cast<AlterTableHandler::FieldActionBase*>(it.value())->fieldName();
- else
+ }
+ else {
fieldName = "??";
+ }
QString dbg = QString("Action dict for field \"%1\" (%2, UID=%3):")
.arg(fieldName).arg(dict->count()).arg(fieldUID);
KexiDBDbg << dbg;
@@ -286,7 +292,7 @@
if (simulate)
KexiUtils::addAlterTableActionDebug("** Simplified Field Actions:");
#endif
- for (AlterTableHandler::ActionDictDictIterator it(fieldActions.constBegin()); it \
!= fieldActions.constEnd(); ++it) { + for \
(AlterTableHandler::ActionDictDictConstIterator it(fieldActions.constBegin()); it != \
fieldActions.constEnd(); ++it) { debugActionDict(it.value(), it.key(), simulate);
}
}
@@ -483,6 +489,7 @@
AlterTableHandler::RemoveFieldAction::~RemoveFieldAction()
{
+ kDebug() << this;
}
void AlterTableHandler::RemoveFieldAction::updateAlteringRequirements()
@@ -561,6 +568,7 @@
AlterTableHandler::InsertFieldAction::~InsertFieldAction()
{
+ kDebug() << this;
delete m_field;
}
@@ -618,7 +626,9 @@
if (actionsForThisField) {
//collect property values that have to be changed in this field
QHash<QByteArray, QVariant> values;
- for (ActionDictIterator it(actionsForThisField->constBegin()); it != \
actionsForThisField->constEnd();) { + ActionDict *newActionsForThisField = new \
ActionDict(); // this will replace actionsForThisField after the loop + \
QSet<ActionBase*> actionsToDelete; // used to collect actions taht we soon delete but \
cannot delete in the loop below + for (ActionDictConstIterator \
it(actionsForThisField->constBegin()); it != \
actionsForThisField->constEnd();++it) {
ChangeFieldPropertyAction* changePropertyAction = \
dynamic_cast<ChangeFieldPropertyAction*>(it.value()); if (changePropertyAction) {
//if this field is going to be renamed, also update fieldName()
@@ -627,11 +637,18 @@
}
values.insert(changePropertyAction->propertyName().toLatin1(), \
changePropertyAction->newValue());
//the subsequent "change property" action is no longer needed
- actionsForThisField->remove(changePropertyAction->propertyName().toLatin1());
+ actionsToDelete.insert(it.value());
} else {
- ++it;
+ //keep
+ newActionsForThisField->insert(it.key(), it.value());
}
}
+ qDeleteAll(actionsToDelete);
+ actionsForThisField->setAutoDelete(false);
+ delete actionsForThisField;
+ actionsForThisField = newActionsForThisField;
+ fieldActions.take(uid());
+ fieldActions.insert(uid(), actionsForThisField);
if (!values.isEmpty()) {
//update field, so it will be created as one step
KexiDB::Field *f = new KexiDB::Field(field());
@@ -697,6 +714,7 @@
AlterTableHandler::MoveFieldPositionAction::~MoveFieldPositionAction()
{
+ kDebug() << this;
}
void AlterTableHandler::MoveFieldPositionAction::updateAlteringRequirements()
@@ -739,6 +757,7 @@
AlterTableHandler::~AlterTableHandler()
{
+ kDebug() << this;
delete d;
}
@@ -861,8 +880,8 @@
args.requirements = 0;
QSet<QString> fieldsWithChangedMainSchema; // Used to collect fields with \
changed main schema.
// This will be used when recreateTable is false to update kexi__fields
- for (ActionDictDictIterator it(fieldActions.constBegin()); it != \
fieldActions.constEnd(); ++it) {
- for (AlterTableHandler::ActionDictIterator it2(it.value()->constBegin());
+ for (ActionDictDictConstIterator it(fieldActions.constBegin()); it != \
fieldActions.constEnd(); ++it) { + for \
(AlterTableHandler::ActionDictConstIterator \
it2(it.value()->constBegin());
it2 != it.value()->constEnd(); ++it2, ++currentActionsCount) {
if (it2.value()->shouldBeRemoved(fieldActions))
continue;
--- trunk/koffice/kexi/kexidb/alter.h #1116240:1116241
@@ -144,8 +144,10 @@
//! For collecting actions related to a single field
typedef KexiUtils::AutodeletedHash<QByteArray, ActionBase*> ActionDict;
typedef KexiUtils::AutodeletedHash<int, ActionDict*> ActionDictDict; //!< for \
collecting groups of actions by field UID
- typedef QHash<QByteArray, ActionBase*>::ConstIterator ActionDictIterator;
- typedef QHash<int, ActionDict*>::ConstIterator ActionDictDictIterator;
+ typedef QHash<QByteArray, ActionBase*>::Iterator ActionDictIterator;
+ typedef QHash<QByteArray, ActionBase*>::ConstIterator ActionDictConstIterator;
+ typedef QHash<int, ActionDict*>::Iterator ActionDictDictIterator;
+ typedef QHash<int, ActionDict*>::ConstIterator ActionDictDictConstIterator;
typedef QVector<ActionBase*> ActionsVector; //!< for collecting actions related \
to a single field
//! Defines a type for action list.
--- trunk/koffice/kexi/kexidb/drivermanager.cpp #1116240:1116241
@@ -176,7 +176,7 @@
KexiDB::Driver::Info DriverManagerInternal::driverInfo(const QString &name)
{
- KexiDB::Driver::Info i = m_driversInfo[name.toLower()];
+ KexiDB::Driver::Info i = m_driversInfo.value(name.toLower());
if (!error() && i.name.isEmpty())
setError(ERR_DRIVERMANAGER, i18n("Could not find database driver \"%1\".", \
name)); return i;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic