src/ldtypes.cpp

changeset 486
25747c37c7be
parent 484
5b5c77c7f3dd
child 489
0b32138fedcc
child 493
16766ac1bbd9
equal deleted inserted replaced
485:543a6696096f 486:25747c37c7be
645 // Hook the set accessors of certain properties to this changeProperty function. 645 // Hook the set accessors of certain properties to this changeProperty function.
646 // It takes care of history management so we can capture low-level changes, this 646 // It takes care of history management so we can capture low-level changes, this
647 // makes history stuff work out of the box. 647 // makes history stuff work out of the box.
648 // ----------------------------------------------------------------------------- 648 // -----------------------------------------------------------------------------
649 template<class T> void changeProperty (LDObject* obj, T* ptr, const T& val) { 649 template<class T> void changeProperty (LDObject* obj, T* ptr, const T& val) {
650 if (obj->file()) { 650 long idx;
651 long idx = obj->getIndex(); 651
652 if (obj->file() && (idx = obj->getIndex()) != -1) {
652 str before = obj->raw(); 653 str before = obj->raw();
653 *ptr = val; 654 *ptr = val;
654 str after = obj->raw(); 655 str after = obj->raw();
655 656
656 obj->file()->addToHistory (new EditHistory (idx, before, after)); 657 obj->file()->addToHistory (new EditHistory (idx, before, after));

mercurial