Do the screenshot in the savestate callback

This commit is contained in:
Jean-André Santoni 2016-12-01 22:38:56 +01:00
parent 24a689c274
commit 2cc4bef3aa
3 changed files with 27 additions and 3 deletions

View File

@ -1683,8 +1683,6 @@ static void command_event_main_state(unsigned cmd)
switch (cmd)
{
case CMD_EVENT_SAVE_STATE:
if (settings->savestate_thumbnail_enable)
take_savestate_screenshot(path);
content_save_state(path, true, false);
push_msg = false;
break;

View File

@ -504,6 +504,8 @@ static void undo_save_state_cb(void *task_data,
static void task_save_handler_finished(retro_task_t *task,
save_task_state_t *state)
{
save_task_state_t *task_data = NULL;
task->finished = true;
filestream_close(state->file);
@ -511,6 +513,11 @@ static void task_save_handler_finished(retro_task_t *task,
if (!task->error && task->cancelled)
task->error = strdup("Task canceled");
task_data = (save_task_state_t*)calloc(1, sizeof(*task_data));
memcpy(task_data, state, sizeof(*state));
task->task_data = task_data;
if (state->data)
{
if (state->undo_save && state->data == undo_save_buf.data)
@ -970,6 +977,24 @@ error:
free(load_data);
}
/**
* save_state_cb:
*
* Called after the save state is done. Takes a screenshot if needed.
**/
static void save_state_cb(void *task_data,
void *user_data, const char *error)
{
settings_t *settings = config_get_ptr();
save_task_state_t *state = (save_task_state_t*)task_data;
char *path = strdup(state->path);
if (settings->savestate_thumbnail_enable)
take_savestate_screenshot(path);
free(path);
}
/**
* task_push_save_state:
* @path : file path of the save state
@ -995,6 +1020,7 @@ static void task_push_save_state(const char *path, void *data, size_t size, bool
task->type = TASK_TYPE_BLOCKING;
task->state = state;
task->handler = task_save_handler;
task->callback = save_state_cb;
task->title = strdup(msg_hash_to_str(MSG_SAVING_STATE));
task->mute = state->mute;

View File

@ -212,7 +212,7 @@ static bool screenshot_dump(
}
#endif
task->type = TASK_TYPE_NONE;
task->type = TASK_TYPE_BLOCKING;
task->state = state;
task->handler = task_screenshot_handler;
if (!savestate)