Revision 5f28a7bf src/vm/VirtualMachine.cc

View differences:

src/vm/VirtualMachine.cc
505 505
        return rc;
506 506
    }
507 507

  
508
    //Get History Records. Current history is built in from_xml() (if any).
508
    //Get History Records. 
509 509
    if( hasHistory() )
510 510
    {
511
        last_seq = history->seq - 1;
511
        last_seq = history->seq;
512

  
513
        delete history_records[last_seq];
512 514

  
513 515
        for (int i = last_seq; i >= 0; i--)
514 516
        {
......
526 528

  
527 529
            if ( i == last_seq )
528 530
            {
531
                history = hp;
532
            }
533
            else if ( i == last_seq - 1 )
534
            {
529 535
                previous_history = hp;
530 536
            }
531 537
        }
......
2117 2123
    // -------------------------------------------------------------------------
2118 2124
    // Last history entry
2119 2125
    // -------------------------------------------------------------------------
2120
    ObjectXML::get_nodes("/VM/HISTORY_RECORDS/HISTORY", content);
2126
    int last_seq;
2121 2127

  
2122
    if (!content.empty())
2128
    if ( xpath(last_seq,"/VM/HISTORY_RECORDS/HISTORY/SEQ", -1) == 0 && 
2129
            last_seq != -1 )
2123 2130
    {
2124
        history = new History(oid);
2125
        rc += history->from_xml_node(content[0]);
2131
        history = new History(oid, last_seq);
2126 2132

  
2127 2133
        history_records.resize(history->seq + 1);
2128 2134
        history_records[history->seq] = history;
2129

  
2130
        ObjectXML::free_nodes(content);
2131
        content.clear();
2132 2135
    }
2133 2136

  
2134 2137
    // -------------------------------------------------------------------------

Also available in: Unified diff