Throughout the file p->modified is set before the call to dt_dev_add_history_item - I'd move this to camera_menu_select.