Implement JS delay workaround. #187
yoshimi-0.060.10 jack session implementation is broken. Save complete reply is sent from the jack session callback but the actual save is made asynchronously, in the main thread, on next main loop iteration. This changeset implements workaround for app bugs like this. User is able to set JS delay in seconds. Default is zero.
This commit is contained in:
parent
02dfa258f2
commit
640ca88481
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* LADI Session Handler (ladish)
|
* LADI Session Handler (ladish)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
* Copyright (C) 2010,2011 Nedko Arnaudov <nedko@arnaudov.name>
|
||||||
*
|
*
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* This file contains defines for conf keys
|
* This file contains defines for conf keys
|
||||||
|
@ -31,10 +31,12 @@
|
||||||
#define LADISH_CONF_KEY_DAEMON_SHELL "/org/ladish/daemon/shell"
|
#define LADISH_CONF_KEY_DAEMON_SHELL "/org/ladish/daemon/shell"
|
||||||
#define LADISH_CONF_KEY_DAEMON_TERMINAL "/org/ladish/daemon/terminal"
|
#define LADISH_CONF_KEY_DAEMON_TERMINAL "/org/ladish/daemon/terminal"
|
||||||
#define LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART "/org/ladish/daemon/studio_autostart"
|
#define LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART "/org/ladish/daemon/studio_autostart"
|
||||||
|
#define LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY "/org/ladish/daemon/js_save_delay"
|
||||||
|
|
||||||
#define LADISH_CONF_KEY_DAEMON_NOTIFY_DEFAULT true
|
#define LADISH_CONF_KEY_DAEMON_NOTIFY_DEFAULT true
|
||||||
#define LADISH_CONF_KEY_DAEMON_SHELL_DEFAULT "sh"
|
#define LADISH_CONF_KEY_DAEMON_SHELL_DEFAULT "sh"
|
||||||
#define LADISH_CONF_KEY_DAEMON_TERMINAL_DEFAULT "xterm"
|
#define LADISH_CONF_KEY_DAEMON_TERMINAL_DEFAULT "xterm"
|
||||||
#define LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART_DEFAULT true
|
#define LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART_DEFAULT true
|
||||||
|
#define LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY_DEFAULT 0
|
||||||
|
|
||||||
#endif /* #ifndef CONF_H__795797BE_4EB8_44F8_BD9C_B8A9CB975228__INCLUDED */
|
#endif /* #ifndef CONF_H__795797BE_4EB8_44F8_BD9C_B8A9CB975228__INCLUDED */
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include "../common/catdup.h"
|
#include "../common/catdup.h"
|
||||||
#include "studio.h"
|
#include "studio.h"
|
||||||
#include "../proxies/jack_proxy.h"
|
#include "../proxies/jack_proxy.h"
|
||||||
|
#include "../proxies/conf_proxy.h"
|
||||||
|
#include "conf.h"
|
||||||
|
|
||||||
struct ladish_js_find_app_client_context
|
struct ladish_js_find_app_client_context
|
||||||
{
|
{
|
||||||
|
@ -143,12 +145,26 @@ struct ladish_js_save_app_context
|
||||||
void ladish_js_save_app_complete(void * context, const char * commandline)
|
void ladish_js_save_app_complete(void * context, const char * commandline)
|
||||||
{
|
{
|
||||||
int iret;
|
int iret;
|
||||||
|
unsigned int delay;
|
||||||
|
|
||||||
if (commandline == NULL)
|
if (commandline == NULL)
|
||||||
{
|
{
|
||||||
goto call;
|
goto call;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_info("JS app save complete. commandline='%s'", commandline);
|
||||||
|
|
||||||
|
if (!conf_get_uint(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY, &delay))
|
||||||
|
{
|
||||||
|
delay = LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delay > 0)
|
||||||
|
{
|
||||||
|
log_info("sleeping for %u seconds...", delay);
|
||||||
|
sleep(delay);
|
||||||
|
}
|
||||||
|
|
||||||
iret = rename(ctx_ptr->client_dir, ctx_ptr->target_dir);
|
iret = rename(ctx_ptr->client_dir, ctx_ptr->target_dir);
|
||||||
if (iret != 0)
|
if (iret != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -356,6 +356,11 @@ int main(int argc, char ** argv, char ** envp)
|
||||||
goto uninit_conf;
|
goto uninit_conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!conf_register(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY, NULL, NULL))
|
||||||
|
{
|
||||||
|
goto uninit_conf;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ladish_recent_projects_init())
|
if (!ladish_recent_projects_init())
|
||||||
{
|
{
|
||||||
goto uninit_conf;
|
goto uninit_conf;
|
||||||
|
|
|
@ -1741,7 +1741,7 @@ along with LADI Session Handler; if not, write to the Free Software Foundation,
|
||||||
<object class="GtkTable" id="settings_string_table">
|
<object class="GtkTable" id="settings_string_table">
|
||||||
<property name="column_spacing">5</property>
|
<property name="column_spacing">5</property>
|
||||||
<property name="n_columns">2</property>
|
<property name="n_columns">2</property>
|
||||||
<property name="n_rows">2</property>
|
<property name="n_rows">3</property>
|
||||||
<property name="row_spacing">5</property>
|
<property name="row_spacing">5</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -1786,6 +1786,33 @@ along with LADI Session Handler; if not, write to the Free Software Foundation,
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="settings_js_delay_label">
|
||||||
|
<property name="label" translatable="yes">JS delay (seconds):</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="settings_js_delay_spin">
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="invisible_char">●</property>
|
||||||
|
<property name="numeric">True</property>
|
||||||
|
<property name="digits">0</property>
|
||||||
|
<property name="snap_to_ticks">True</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* LADI Session Handler (ladish)
|
* LADI Session Handler (ladish)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008, 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
* Copyright (C) 2008,2009,2010,2011 Nedko Arnaudov <nedko@arnaudov.name>
|
||||||
*
|
*
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* This file contains the code that implements main() and other top-level functionality
|
* This file contains the code that implements main() and other top-level functionality
|
||||||
|
@ -161,6 +161,11 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!conf_register(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY, NULL, NULL))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!init_jack())
|
if (!init_jack())
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* LADI Session Handler (ladish)
|
* LADI Session Handler (ladish)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
* Copyright (C) 2010,2011 Nedko Arnaudov <nedko@arnaudov.name>
|
||||||
*
|
*
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* This file contains implementation of the settings dialog
|
* This file contains implementation of the settings dialog
|
||||||
|
@ -37,15 +37,18 @@ void menu_request_settings(void)
|
||||||
GtkToggleButton * send_notifications_button;
|
GtkToggleButton * send_notifications_button;
|
||||||
GtkEntry * shell_entry;
|
GtkEntry * shell_entry;
|
||||||
GtkEntry * terminal_entry;
|
GtkEntry * terminal_entry;
|
||||||
|
GtkSpinButton * js_delay_spin;
|
||||||
bool autostart;
|
bool autostart;
|
||||||
bool notify;
|
bool notify;
|
||||||
const char * shell;
|
const char * shell;
|
||||||
const char * terminal;
|
const char * terminal;
|
||||||
|
unsigned int js_delay;
|
||||||
|
|
||||||
autostart_studio_button = GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_studio_autostart_checkbutton"));
|
autostart_studio_button = GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_studio_autostart_checkbutton"));
|
||||||
send_notifications_button = GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_send_notifications_checkbutton"));
|
send_notifications_button = GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_send_notifications_checkbutton"));
|
||||||
shell_entry = GTK_ENTRY(get_gtk_builder_widget("settings_shell_entry"));
|
shell_entry = GTK_ENTRY(get_gtk_builder_widget("settings_shell_entry"));
|
||||||
terminal_entry = GTK_ENTRY(get_gtk_builder_widget("settings_terminal_entry"));
|
terminal_entry = GTK_ENTRY(get_gtk_builder_widget("settings_terminal_entry"));
|
||||||
|
js_delay_spin = GTK_SPIN_BUTTON(get_gtk_builder_widget("settings_js_delay_spin"));
|
||||||
|
|
||||||
dialog = GTK_DIALOG(get_gtk_builder_widget("settings_dialog"));
|
dialog = GTK_DIALOG(get_gtk_builder_widget("settings_dialog"));
|
||||||
|
|
||||||
|
@ -69,12 +72,21 @@ void menu_request_settings(void)
|
||||||
terminal = LADISH_CONF_KEY_DAEMON_TERMINAL_DEFAULT;
|
terminal = LADISH_CONF_KEY_DAEMON_TERMINAL_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!conf_get_uint(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY, &js_delay))
|
||||||
|
{
|
||||||
|
js_delay = LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_toggle_button_set_active(autostart_studio_button, autostart);
|
gtk_toggle_button_set_active(autostart_studio_button, autostart);
|
||||||
gtk_toggle_button_set_active(send_notifications_button, notify);
|
gtk_toggle_button_set_active(send_notifications_button, notify);
|
||||||
|
|
||||||
gtk_entry_set_text(shell_entry, shell);
|
gtk_entry_set_text(shell_entry, shell);
|
||||||
gtk_entry_set_text(terminal_entry, terminal);
|
gtk_entry_set_text(terminal_entry, terminal);
|
||||||
|
|
||||||
|
gtk_spin_button_set_range(js_delay_spin, 0, 1000);
|
||||||
|
gtk_spin_button_set_increments(js_delay_spin, 1, 2);
|
||||||
|
gtk_spin_button_set_value(js_delay_spin, js_delay);
|
||||||
|
|
||||||
gtk_widget_show(GTK_WIDGET(dialog));
|
gtk_widget_show(GTK_WIDGET(dialog));
|
||||||
result = gtk_dialog_run(GTK_DIALOG(dialog));
|
result = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
gtk_widget_hide(GTK_WIDGET(dialog));
|
gtk_widget_hide(GTK_WIDGET(dialog));
|
||||||
|
@ -87,11 +99,13 @@ void menu_request_settings(void)
|
||||||
notify = gtk_toggle_button_get_active(send_notifications_button);
|
notify = gtk_toggle_button_get_active(send_notifications_button);
|
||||||
shell = gtk_entry_get_text(shell_entry);
|
shell = gtk_entry_get_text(shell_entry);
|
||||||
terminal = gtk_entry_get_text(terminal_entry);
|
terminal = gtk_entry_get_text(terminal_entry);
|
||||||
|
js_delay = gtk_spin_button_get_value(js_delay_spin);
|
||||||
|
|
||||||
if (!conf_set_bool(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, autostart) ||
|
if (!conf_set_bool(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, autostart) ||
|
||||||
!conf_set_bool(LADISH_CONF_KEY_DAEMON_NOTIFY, notify) ||
|
!conf_set_bool(LADISH_CONF_KEY_DAEMON_NOTIFY, notify) ||
|
||||||
!conf_set(LADISH_CONF_KEY_DAEMON_SHELL, shell) ||
|
!conf_set(LADISH_CONF_KEY_DAEMON_SHELL, shell) ||
|
||||||
!conf_set(LADISH_CONF_KEY_DAEMON_TERMINAL, terminal))
|
!conf_set(LADISH_CONF_KEY_DAEMON_TERMINAL, terminal) ||
|
||||||
|
!conf_set_uint(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY, js_delay))
|
||||||
{
|
{
|
||||||
error_message_box(_("Storing settings"));
|
error_message_box(_("Storing settings"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,3 +354,69 @@ bool conf_get_bool(const char * key, bool * value_ptr)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* UINT_MAX is 10 chars + terminating nul */
|
||||||
|
#define UINT_STRING_MAX_SIZE 11
|
||||||
|
|
||||||
|
static const char * conf_uint2string(unsigned int value, char * string)
|
||||||
|
{
|
||||||
|
char * ptr;
|
||||||
|
|
||||||
|
ptr = string + (UINT_STRING_MAX_SIZE - 1);
|
||||||
|
*ptr = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ASSERT(ptr > string); /* UINT_STRING_MAX_SIZE is too small? */
|
||||||
|
ptr--;
|
||||||
|
*ptr = '0' + value % 10;
|
||||||
|
value /= 10;
|
||||||
|
}
|
||||||
|
while (value > 0);
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool conf_string2uint(const char * string, unsigned int * value_ptr)
|
||||||
|
{
|
||||||
|
unsigned int value;
|
||||||
|
|
||||||
|
value = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (*string < '0' || *string > '9')
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
value *= 10;
|
||||||
|
value += *string - '0';
|
||||||
|
|
||||||
|
string++;
|
||||||
|
}
|
||||||
|
while (*string != 0);
|
||||||
|
|
||||||
|
*value_ptr = value;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool conf_set_uint(const char * key, unsigned int value)
|
||||||
|
{
|
||||||
|
char buffer[UINT_STRING_MAX_SIZE];
|
||||||
|
|
||||||
|
return conf_set(key, conf_uint2string(value, buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool conf_get_uint(const char * key, unsigned int * value_ptr)
|
||||||
|
{
|
||||||
|
const char * str;
|
||||||
|
|
||||||
|
if (!conf_get(key, &str))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return conf_string2uint(str, value_ptr);
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* LADI Session Handler (ladish)
|
* LADI Session Handler (ladish)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
* Copyright (C) 2010,2011 Nedko Arnaudov <nedko@arnaudov.name>
|
||||||
*
|
*
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* This file contains interface to code that interfaces ladiconfd through D-Bus
|
* This file contains interface to code that interfaces ladiconfd through D-Bus
|
||||||
|
@ -47,4 +47,7 @@ const char * conf_bool2string(bool value);
|
||||||
bool conf_set_bool(const char * key, bool value);
|
bool conf_set_bool(const char * key, bool value);
|
||||||
bool conf_get_bool(const char * key, bool * value_ptr);
|
bool conf_get_bool(const char * key, bool * value_ptr);
|
||||||
|
|
||||||
|
bool conf_set_uint(const char * key, unsigned int value);
|
||||||
|
bool conf_get_uint(const char * key, unsigned int * value_ptr);
|
||||||
|
|
||||||
#endif /* #ifndef CONF_PROXY_H__D45503B2_D49C_46BF_86F7_9A531B819B6B__INCLUDED */
|
#endif /* #ifndef CONF_PROXY_H__D45503B2_D49C_46BF_86F7_9A531B819B6B__INCLUDED */
|
||||||
|
|
Loading…
Reference in New Issue