void RemoveImage::revert(ObjectsContainer* objects, UndoersCollector* redoers) { Stock* stock = objects->getObjectT<Stock>(m_stockId); Image* image = read_object<Image>(objects, m_stream, raster::read_image); // Push an AddImage as redoer redoers->pushUndoer(new AddImage(objects, stock, m_imageIndex)); stock->replaceImage(m_imageIndex, image); }
void ReplaceImage::revert(ObjectsContainer* objects, UndoersCollector* redoers) { Stock* stock = objects->getObjectT<Stock>(m_stockId); // Read the image to be restored from the stream Image* image = read_object<Image>(objects, m_stream, raster::read_image); // Save the current image in the redoers redoers->pushUndoer(new ReplaceImage(objects, stock, m_imageIndex)); Image* oldImage = stock->getImage(m_imageIndex); // Replace the image in the stock stock->replaceImage(m_imageIndex, image); // Destroy the old image delete oldImage; }