[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [okteta] kasten/controllers/view/structures/datatypes: structures: fix model getting corrupted when
From:       Alex Richardson <arichardson.kde () googlemail ! com>
Date:       2013-06-30 20:57:52
Message-ID: E1UtOgy-0004kc-Ib () scm ! kde ! org
[Download RAW message or body]

Git commit 717c58b0ae7e7bccdcc3e9c028c8c68bf7be2f9a by Alex Richardson.
Committed on 21/03/2013 at 13:53.
Pushed by arichardson into branch 'master'.

structures: fix model getting corrupted when tagged union changes type

M  +12   -0    kasten/controllers/view/structures/datatypes/taggeduniondatainformation.cpp


http://commits.kde.org/okteta/717c58b0ae7e7bccdcc3e9c028c8c68bf7be2f9a

diff --git a/kasten/controllers/view/structures/datatypes/taggeduniondatainformation.cpp \
b/kasten/controllers/view/structures/datatypes/taggeduniondatainformation.cpp index \
                be9790c..dfff695 100644
--- a/kasten/controllers/view/structures/datatypes/taggeduniondatainformation.cpp
+++ b/kasten/controllers/view/structures/datatypes/taggeduniondatainformation.cpp
@@ -151,11 +151,23 @@ qint64 \
TaggedUnionDataInformation::readData(Okteta::AbstractByteArrayModel *inpu  \
TopLevelDataInformation* top = topLevelDataInformation();  Q_CHECK_PTR(top);
 
+    const QVector<DataInformation*>& oldChildren = currentChildren();
+
     qint64 readBits = 0;
     mWasAbleToRead = StructureDataInformation::readChildren(mChildren,
             input, address, bitsRemaining, bitOffset, &readBits, top);
     mLastIndex = determineSelection(top);
     const QVector<DataInformation*>& others = currentChildren();
+    //check whether we have different children now, if yes we have to emit child \
count changed +    if (oldChildren != others) {
+        const int fixedSize = mChildren.size();
+        //tell the model that all children have changed by setting to 0 and then to \
new size +        top->_childCountAboutToChange(this, fixedSize + oldChildren.size(), \
fixedSize); +        top->_childCountChanged(this, fixedSize + oldChildren.size(), \
fixedSize); +        top->_childCountAboutToChange(this, fixedSize, fixedSize + \
others.size()); +        top->_childCountChanged(this, fixedSize, fixedSize + \
others.size()); +    }
+
     //this is important since the remaining children might have changed since before \
the read  //where beginRead was called on the children at that time
     for (int i = 0; i < others.size(); i++)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic