# --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: package/.../koffice/0002-koffice-2.3-kexi-fix-insert-required-value.patch # Copyright (C) 2011 The OpenSDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- SDE-COPYRIGHT-NOTE-END --- diff --git a/kexi/widget/tableview/kexitableviewdata.cpp b/kexi/widget/tableview/kexitableviewdata.cpp index 845c0aa..9dc89d7 100644 --- a/kexi/widget/tableview/kexitableviewdata.cpp +++ b/kexi/widget/tableview/kexitableviewdata.cpp @@ -565,12 +565,12 @@ bool KexiTableViewData::updateRowEditBufferRef(KexiDB::RecordData *record, //get a new value (if present in the buffer), or the old one, otherwise //(taken here for optimization) -#define GET_VALUE if (!val) { \ - val = d->cursor \ +#define GET_VALUE if (!pval) { \ + pval = d->cursor \ ? d->pRowEditBuffer->at( *(*it_f)->columnInfo(), (*it_r).isNull() /* useDefaultValueIfPossible */ ) \ : d->pRowEditBuffer->at( *f ); \ - if (!val) \ - val = &(*it_r); /* get old value */ \ + val = pval ? *pval : *it_r; /* get old value */ \ + /*kDebug() << col << (*it_f)->columnInfo()->debugString() << "val:" << val;*/ \ } //! @todo if there're multiple views for this data, we need multiple buffers! @@ -584,13 +584,14 @@ bool KexiTableViewData::saveRow(KexiDB::RecordData& record, bool insert, bool re KexiTableViewColumn::ListIterator it_f(m_columns.constBegin()); KexiDB::RecordData::ConstIterator it_r = record.constBegin(); int col = 0; - const QVariant *val = 0; + const QVariant *pval = 0; + QVariant val; for (;it_f != m_columns.constEnd() && it_r != record.constEnd();++it_f, ++it_r, col++) { KexiDB::Field *f = (*it_f)->field(); if (f->isNotNull()) { GET_VALUE; //check it - if (val->isNull() && !f->isAutoIncrement()) { + if (val.isNull() && !f->isAutoIncrement()) { //NOT NULL violated d->result.msg = i18n("\"%1\" column requires a value to be entered.", f->captionOrName()) + "\n\n" + Kexi::msgYouCanImproveData(); @@ -601,7 +602,7 @@ bool KexiTableViewData::saveRow(KexiDB::RecordData& record, bool insert, bool re } if (f->isNotEmpty()) { GET_VALUE; - if (!f->isAutoIncrement() && (val->isNull() || KexiDB::isEmptyValue(f, *val))) { + if (!f->isAutoIncrement() && (val.isNull() || KexiDB::isEmptyValue(f, val))) { //NOT EMPTY violated d->result.msg = i18n("\"%1\" column requires a value to be entered.", f->captionOrName()) + "\n\n" + Kexi::msgYouCanImproveData();