check if layout-demand-handler exists every time it is called
This commit is contained in:
33
riverguile.c
33
riverguile.c
@@ -56,12 +56,33 @@ static bool scm2uint(uint32_t *x, SCM s)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to find a variable named 'name' and returns it, otherwise #f is returned.
|
||||
*/
|
||||
static SCM scm_c_get_variable (const char *name)
|
||||
{
|
||||
return scm_module_variable(
|
||||
scm_current_module(),
|
||||
scm_string_to_symbol(
|
||||
scm_from_utf8_string(name)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
static void *call_layout_demand_handler (void *data)
|
||||
{
|
||||
struct Layout_demand_parameters *params = (struct Layout_demand_parameters *)data;
|
||||
|
||||
SCM layout_demand_handler = scm_c_get_variable("layout-demand-handler");
|
||||
if ( scm_is_false(layout_demand_handler) == 1 )
|
||||
{
|
||||
ret = EXIT_FAILURE;
|
||||
loop = false;
|
||||
return (void *)"ERROR: layout-demand-handler no longer exists.\n";
|
||||
}
|
||||
|
||||
SCM call_result = scm_call_3(
|
||||
scm_variable_ref(scm_c_lookup("layout-demand-handler")),
|
||||
scm_variable_ref(layout_demand_handler),
|
||||
scm_from_uint32(params->view_count),
|
||||
scm_from_uint32(params->width),
|
||||
scm_from_uint32(params->height)
|
||||
@@ -320,14 +341,8 @@ static void *load_script (void *data)
|
||||
scm_primitive_load_path(scm_from_utf8_string(path));
|
||||
|
||||
/* Check if the handler has been defined. */
|
||||
SCM variable = scm_module_variable(
|
||||
scm_current_module(),
|
||||
scm_string_to_symbol(
|
||||
scm_from_utf8_string("layout-demand-handler")
|
||||
)
|
||||
);
|
||||
|
||||
if ( scm_is_false(variable) == 1 )
|
||||
SCM layout_demand_handler = scm_c_get_variable("layout-demand-handler");
|
||||
if ( scm_is_false(layout_demand_handler) == 1 )
|
||||
{
|
||||
ret = EXIT_FAILURE;
|
||||
loop = false;
|
||||
|
||||
Reference in New Issue
Block a user