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)); |