static void make_backup(void){ if (Undo_num_undos() == 0) return; if (dc.filename==NULL) return; if (!editor_has_keyboard_focus()) // If showing popup menu, editing text widgets, etc. we don't want to disturb the user. return; if (g_undo_generation_for_last_backup == g_curr_undo_generation) return; // Set this immediately so we don't start several BackupTimers. g_undo_generation_for_last_backup = g_curr_undo_generation; root->song->tracker_windows->message = "Please wait. Saving backup"; GL_create(root->song->tracker_windows, root->song->tracker_windows->wblock); wchar_t *backup_filename = get_backup_filename(); Save_Backup(backup_filename, root); root->song->tracker_windows->message = NULL; GL_create(root->song->tracker_windows, root->song->tracker_windows->wblock); //printf(" BACKUP finished\n"); }
void BACKUP_call_very_often(void){ if (MIXER_is_saving()) return; if (g_radium_runs_custom_exec) return; static bool has_inited = false; if (has_inited==false){ RT_BACKUP_reset_timer(); has_inited=true; } if (!editor_has_keyboard_focus()) // If showing popup menu, editing text widgets, etc. we don't want to disturb the user. return; if (QApplication::mouseButtons() != Qt::NoButton) // Wait until user doesn't use the mouse. return; static bool is_playing = false; Player_State player_state = ATOMIC_GET(pc->player_state); if (!is_playing && player_state==PLAYER_STATE_PLAYING){ is_playing = true; g_curr_playing_start_time = TIME_get_ms(); } if (is_playing && player_state==PLAYER_STATE_STOPPED){ is_playing = false; double added_playing_duration = TIME_get_ms() - g_curr_playing_start_time; g_curr_playing_duration += added_playing_duration; } if (!doSaveBackupWhilePlaying()) if (is_playing) return; //printf("duration: %f\n",get_unbackuped_duration() / 1000.0); if (SampleRecorder_Get_Num_Instances() > 0) return; if (get_unbackuped_duration() > get_backup_interval_ms()){ make_backup(); RT_BACKUP_reset_timer(); } }