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/taggeduniondata= information.cpp http://commits.kde.org/okteta/717c58b0ae7e7bccdcc3e9c028c8c68bf7be2f9a diff --git a/kasten/controllers/view/structures/datatypes/taggeduniondatain= formation.cpp b/kasten/controllers/view/structures/datatypes/taggeduniondat= ainformation.cpp index be9790c..dfff695 100644 --- a/kasten/controllers/view/structures/datatypes/taggeduniondatainformati= on.cpp +++ b/kasten/controllers/view/structures/datatypes/taggeduniondatainformati= on.cpp @@ -151,11 +151,23 @@ qint64 TaggedUnionDataInformation::readData(Okteta::A= bstractByteArrayModel *inpu TopLevelDataInformation* top =3D topLevelDataInformation(); Q_CHECK_PTR(top); = + const QVector& oldChildren =3D currentChildren(); + qint64 readBits =3D 0; mWasAbleToRead =3D StructureDataInformation::readChildren(mChildren, input, address, bitsRemaining, bitOffset, &readBits, top); mLastIndex =3D determineSelection(top); const QVector& others =3D currentChildren(); + //check whether we have different children now, if yes we have to emit= child count changed + if (oldChildren !=3D others) { + const int fixedSize =3D mChildren.size(); + //tell the model that all children have changed by setting to 0 an= d then to new size + top->_childCountAboutToChange(this, fixedSize + oldChildren.size()= , fixedSize); + top->_childCountChanged(this, fixedSize + oldChildren.size(), fixe= dSize); + top->_childCountAboutToChange(this, fixedSize, fixedSize + others.= size()); + top->_childCountChanged(this, fixedSize, fixedSize + others.size()= ); + } + //this is important since the remaining children might have changed si= nce before the read //where beginRead was called on the children at that time for (int i =3D 0; i < others.size(); i++)