Commit 0fefd8db authored by Jarosław Staniek's avatar Jarosław Staniek
Browse files

KexiDB: fix crashed when saving query design

*put DESC/ASC after COLLATE section, not before (needed at least for sqlite driver)
*fixed crash because of invalid deletion order of query structures
*fixed crash because of invalid deletion relationship structures
BUG:298197

REVIEW:104833
parent 74642dd2
......@@ -151,6 +151,13 @@ Main Window
*User feedback: added anti-DOS protection when updating feedback ui
*User feedback: added checking format of the .list files to avoid erroneous HTTP requests
~~~~~~~~~~~~~~~~ 2.4.2 ~~~~~~~~~~~~~~~~
KexiDB
*put DESC/ASC after COLLATE section, not before (needed at least for sqlite driver)
*fixed crash because of invalid deletion order of query structures
*fixed crash because of invalid deletion relationship structures
BUG:298197
~~~~~~~~~~~~~~~~ 2.4.1 ~~~~~~~~~~~~~~~~
Tables
......
......@@ -129,15 +129,6 @@ public:
}
}
~QuerySchemaPrivate() {
if (fieldsExpanded)
qDeleteAll(*fieldsExpanded);
delete fieldsExpanded;
if (internalFields) {
qDeleteAll(*internalFields);
delete internalFields;
}
delete fieldsExpandedWithInternalAndRowID;
delete fieldsExpandedWithInternal;
delete orderByColumnList;
delete autoincFields;
delete columnsOrder;
......@@ -148,6 +139,15 @@ public:
delete fakeRowIDCol;
delete fakeRowIDField;
delete ownedVisibleColumns;
if (fieldsExpanded)
qDeleteAll(*fieldsExpanded);
delete fieldsExpanded;
if (internalFields) {
qDeleteAll(*internalFields);
delete internalFields;
}
delete fieldsExpandedWithInternalAndRowID;
delete fieldsExpandedWithInternal;
}
void clear() {
......@@ -171,14 +171,6 @@ public:
orderByColumnList->clear();
}
if (fieldsExpanded) {
qDeleteAll(*fieldsExpanded);
delete fieldsExpanded;
fieldsExpanded = 0;
if (internalFields) {
qDeleteAll(*internalFields);
delete internalFields;
internalFields = 0;
}
delete columnsOrder;
columnsOrder = 0;
delete columnsOrderWithoutAsterisks;
......@@ -192,6 +184,14 @@ public:
columnInfosByName.clear();
delete ownedVisibleColumns;
ownedVisibleColumns = 0;
qDeleteAll(*fieldsExpanded);
delete fieldsExpanded;
fieldsExpanded = 0;
if (internalFields) {
qDeleteAll(*internalFields);
delete internalFields;
internalFields = 0;
}
}
}
......@@ -414,6 +414,7 @@ OrderByColumn::OrderByColumn(Field& field, bool ascending)
OrderByColumn* OrderByColumn::copy(QuerySchema* fromQuery, QuerySchema* toQuery) const
{
//kDebug() << "this=" << this << debugString() << "m_column=" << m_column;
if (m_field) {
return new OrderByColumn(*m_field, m_ascending);
}
......@@ -436,11 +437,13 @@ OrderByColumn* OrderByColumn::copy(QuerySchema* fromQuery, QuerySchema* toQuery)
}
return new OrderByColumn(*columnInfo, m_ascending, m_pos);
}
Q_ASSERT(m_field || m_column);
return 0;
}
OrderByColumn::~OrderByColumn()
{
//kDebug() << this << debugString();
}
QString OrderByColumn::debugString() const
......@@ -459,6 +462,7 @@ QString OrderByColumn::debugString() const
QString OrderByColumn::toSQLString(bool includeTableName, const Driver *drv, int identifierEscaping) const
{
//kDebug() << this << debugString();
const QString orderString(m_ascending ? "" : " DESC");
QString fieldName, tableName, collationString;
if (m_column) {
......@@ -485,7 +489,7 @@ QString OrderByColumn::toSQLString(bool includeTableName, const Driver *drv, int
collationString = drv->collationSQL();
}
}
return tableName + fieldName + orderString + collationString;
return tableName + fieldName + collationString + orderString;
}
//=======================================
......
......@@ -78,7 +78,7 @@ class QuerySchema;
class KEXI_DB_EXPORT Relationship
{
public:
typedef KexiUtils::AutodeletedList<Relationship*> List;
typedef QList<Relationship*> List;
typedef QList<Relationship*>::ConstIterator ListIterator;
/*! Creates uninitialized Relationship object.
......
......@@ -57,6 +57,7 @@
#include <koproperty/Property.h>
#include <koproperty/Set.h>
#include "kexiquerypart.h"
#include "kexiqueryview.h"
#include <KexiWindow.h>
#include <KexiWindowData.h>
#include <kexi_global.h>
......@@ -380,6 +381,10 @@ KexiQueryDesignerGuiEditor::buildSchema(QString *errMsg)
//build query schema
KexiQueryPart::TempData * temp = tempData();
if (temp->query()) {
KexiView *queryDataView = window()->viewForMode(Kexi::DataViewMode);
if (queryDataView) {
dynamic_cast<KexiQueryView*>(queryDataView)->setData(0);
}
temp->clearQuery();
} else {
temp->setQuery(new KexiDB::QuerySchema());
......@@ -946,7 +951,7 @@ void KexiQueryDesignerGuiEditor::showFieldsOrRelationsForQueryInternal(
//4. show ORDER BY information
d->data->clearRowEditBuffer();
const KexiDB::OrderByColumnList orderByColumns(query->orderByColumnList());
KexiDB::OrderByColumnList& orderByColumns = query->orderByColumnList();
QHash<KexiDB::QueryColumnInfo*, int> columnsOrder(
query->columnsOrder(KexiDB::QuerySchema::UnexpandedListWithoutAsterisks));
for (KexiDB::OrderByColumn::ListConstIterator orderByColumnIt(orderByColumns.constBegin());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment