Recently I've been playing around with DCMTK's SR module and I found what I think is a bug in DSRTree::addNode() method. It seems that not all pointers to surrounding nodes get updated which corrupts the whole structure.
I noticed the problem when trying to use DSRDocumentTree::addContentItem() in AM_beforeCurrent mode. Even though this method was returning success, the node wasn't included in the dataset produced by DSRDocumentTree::write(). After some research I came across DSRTree::addNode() routine and noticed that some associations weren't updated, which caused write() method to omit newly inserted item.
I applied a quick patch to fix this behavior, here is diff:
Code: Select all
*** /tmp/dsrtree_old.cc 2010-10-14 15:14:42.000000000 +0200
--- /tmp/dsrtree_new.cc 2012-08-14 22:46:40.264994655 +0200
***************
*** 111,122 ****
--- 111,132 ----
node->Prev = NodeCursor;
node->Next = NodeCursor->Next;
NodeCursor->Next = node;
+ if ( node->Next ) {
+ node->Next->Prev = node;
+ }
++Position;
break;
case AM_beforeCurrent:
node->Prev = NodeCursor->Prev;
node->Next = NodeCursor;
NodeCursor->Prev = node;
+ if ( Position > 1 ) {
+ assert( node->Prev );
+ node->Prev->Next = node;
+ }
+ else if ( Position == 1 && ! NodeCursorStack.empty() ) {
+ NodeCursorStack.top()->Down = node;
+ }
break;
case AM_belowCurrent:
/* store old position */
Paweł