Construct dispatch registry on first use to avoid static init order crash
This commit is contained in:
+13
-6
@@ -118,19 +118,26 @@ std::string Dispatcher::str( void )
|
|||||||
return std::string( assum );
|
return std::string( assum );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* construct on first use to avoid static initialization order crash */
|
||||||
|
DispatchRegistry & Terminal::get_global_dispatch_registry( void )
|
||||||
|
{
|
||||||
|
static DispatchRegistry global_dispatch_registry;
|
||||||
|
return global_dispatch_registry;
|
||||||
|
}
|
||||||
|
|
||||||
static void register_function( Function_Type type,
|
static void register_function( Function_Type type,
|
||||||
std::string dispatch_chars,
|
std::string dispatch_chars,
|
||||||
Function f )
|
Function f )
|
||||||
{
|
{
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
case ESCAPE:
|
case ESCAPE:
|
||||||
global_dispatch_registry.escape.insert( dispatch_map_t::value_type( dispatch_chars, f ) );
|
get_global_dispatch_registry().escape.insert( dispatch_map_t::value_type( dispatch_chars, f ) );
|
||||||
break;
|
break;
|
||||||
case CSI:
|
case CSI:
|
||||||
global_dispatch_registry.CSI.insert( dispatch_map_t::value_type( dispatch_chars, f ) );
|
get_global_dispatch_registry().CSI.insert( dispatch_map_t::value_type( dispatch_chars, f ) );
|
||||||
break;
|
break;
|
||||||
case CONTROL:
|
case CONTROL:
|
||||||
global_dispatch_registry.control.insert( dispatch_map_t::value_type( dispatch_chars, f ) );
|
get_global_dispatch_registry().control.insert( dispatch_map_t::value_type( dispatch_chars, f ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,9 +163,9 @@ void Dispatcher::dispatch( Function_Type type, const Parser::Action *act, Frameb
|
|||||||
|
|
||||||
dispatch_map_t *map = NULL;
|
dispatch_map_t *map = NULL;
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
case ESCAPE: map = &global_dispatch_registry.escape; break;
|
case ESCAPE: map = &get_global_dispatch_registry().escape; break;
|
||||||
case CSI: map = &global_dispatch_registry.CSI; break;
|
case CSI: map = &get_global_dispatch_registry().CSI; break;
|
||||||
case CONTROL: map = &global_dispatch_registry.control; break;
|
case CONTROL: map = &get_global_dispatch_registry().control; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string key = dispatch_chars;
|
std::string key = dispatch_chars;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Terminal {
|
|||||||
DispatchRegistry() : escape(), CSI(), control() {}
|
DispatchRegistry() : escape(), CSI(), control() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static DispatchRegistry global_dispatch_registry;
|
DispatchRegistry & get_global_dispatch_registry( void );
|
||||||
|
|
||||||
class Dispatcher {
|
class Dispatcher {
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user