UI: Add frontend API to defer saving
Allows the ability to perform multiple actions that would normally save, and defer the save until all of those actions are complete. Closes obsproject/obs-studio#1231
This commit is contained in:
parent
0dc9151dbd
commit
439b9e4d15
@ -329,6 +329,16 @@ struct OBSStudioAPI : obs_frontend_callbacks {
|
||||
main->SaveProject();
|
||||
}
|
||||
|
||||
void obs_frontend_defer_save_begin(void) override
|
||||
{
|
||||
QMetaObject::invokeMethod(main, "DeferSaveBegin");
|
||||
}
|
||||
|
||||
void obs_frontend_defer_save_end(void) override
|
||||
{
|
||||
QMetaObject::invokeMethod(main, "DeferSaveEnd");
|
||||
}
|
||||
|
||||
void obs_frontend_add_save_callback(obs_frontend_save_cb callback,
|
||||
void *private_data) override
|
||||
{
|
||||
|
@ -297,6 +297,18 @@ void obs_frontend_save(void)
|
||||
c->obs_frontend_save();
|
||||
}
|
||||
|
||||
void obs_frontend_defer_save_begin(void)
|
||||
{
|
||||
if (callbacks_valid())
|
||||
c->obs_frontend_defer_save_begin();
|
||||
}
|
||||
|
||||
void obs_frontend_defer_save_end(void)
|
||||
{
|
||||
if (callbacks_valid())
|
||||
c->obs_frontend_defer_save_end();
|
||||
}
|
||||
|
||||
void obs_frontend_add_save_callback(obs_frontend_save_cb callback,
|
||||
void *private_data)
|
||||
{
|
||||
|
@ -150,6 +150,8 @@ EXPORT void obs_frontend_replay_buffer_stop(void);
|
||||
EXPORT bool obs_frontend_replay_buffer_active(void);
|
||||
|
||||
EXPORT void obs_frontend_save(void);
|
||||
EXPORT void obs_frontend_defer_save_begin(void);
|
||||
EXPORT void obs_frontend_defer_save_end(void);
|
||||
|
||||
EXPORT obs_output_t *obs_frontend_get_streaming_output(void);
|
||||
EXPORT obs_output_t *obs_frontend_get_recording_output(void);
|
||||
|
@ -61,7 +61,9 @@ struct obs_frontend_callbacks {
|
||||
virtual config_t *obs_frontend_get_profile_config(void)=0;
|
||||
virtual config_t *obs_frontend_get_global_config(void)=0;
|
||||
|
||||
virtual void obs_frontend_save(void)=0;
|
||||
virtual void obs_frontend_save(void) = 0;
|
||||
virtual void obs_frontend_defer_save_begin(void) = 0;
|
||||
virtual void obs_frontend_defer_save_end(void) = 0;
|
||||
virtual void obs_frontend_add_save_callback(
|
||||
obs_frontend_save_cb callback, void *private_data)=0;
|
||||
virtual void obs_frontend_remove_save_callback(
|
||||
|
@ -550,6 +550,19 @@ void OBSBasic::Save(const char *file)
|
||||
obs_data_array_release(savedMultiviewProjectorList);
|
||||
}
|
||||
|
||||
void OBSBasic::DeferSaveBegin()
|
||||
{
|
||||
os_atomic_inc_long(&disableSaving);
|
||||
}
|
||||
|
||||
void OBSBasic::DeferSaveEnd()
|
||||
{
|
||||
long result = os_atomic_dec_long(&disableSaving);
|
||||
if (result == 0) {
|
||||
SaveProject();
|
||||
}
|
||||
}
|
||||
|
||||
static void LoadAudioDevice(const char *name, int channel, obs_data_t *parent)
|
||||
{
|
||||
obs_data_t *data = obs_data_get_obj(parent, name);
|
||||
|
@ -380,6 +380,9 @@ private:
|
||||
obs_data_array_t *savedMultiviewProjectors);
|
||||
|
||||
public slots:
|
||||
void DeferSaveBegin();
|
||||
void DeferSaveEnd();
|
||||
|
||||
void StartStreaming();
|
||||
void StopStreaming();
|
||||
void ForceStopStreaming();
|
||||
|
Loading…
x
Reference in New Issue
Block a user