| 637 // ============================================================================= |
637 // ============================================================================= |
| 638 // Hook the set accessors of certain properties to this changeProperty function. |
638 // Hook the set accessors of certain properties to this changeProperty function. |
| 639 // It takes care of history management so we can capture low-level changes, this |
639 // It takes care of history management so we can capture low-level changes, this |
| 640 // makes history stuff work out of the box. |
640 // makes history stuff work out of the box. |
| 641 template<class T> void changeProperty (LDObject* obj, T* ptr, const T& val) { |
641 template<class T> void changeProperty (LDObject* obj, T* ptr, const T& val) { |
| 642 long idx; |
|
| 643 |
|
| 644 if (obj->file()) { |
642 if (obj->file()) { |
| |
643 long idx = obj->getIndex(); |
| 645 str before = obj->raw(); |
644 str before = obj->raw(); |
| 646 *ptr = val; |
645 *ptr = val; |
| 647 str after = obj->raw(); |
646 str after = obj->raw(); |
| 648 |
647 |
| 649 obj->file()->addToHistory (new EditHistory (idx, before, after)); |
648 obj->file()->addToHistory (new EditHistory (idx, before, after)); |