From: Mikko Rasa Date: Sun, 24 Mar 2013 15:32:01 +0000 (+0200) Subject: Guard against null pointers X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=14e71eccf3a54a056b74266d54ddb70a77528777;p=libs%2Fgltk.git Guard against null pointers --- diff --git a/source/root.cpp b/source/root.cpp index 1dea150..1b47e8a 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -36,12 +36,19 @@ void Root::init() update_style(); - mouse->signal_button_press.connect(sigc::mem_fun(this, &Root::button_press_event)); - mouse->signal_button_release.connect(sigc::mem_fun(this, &Root::button_release_event)); - mouse->signal_axis_motion.connect(sigc::mem_fun(this, &Root::axis_motion_event)); - keyboard->signal_button_press.connect(sigc::mem_fun(this, &Root::key_press_event)); - keyboard->signal_button_release.connect(sigc::mem_fun(this, &Root::key_release_event)); - keyboard->signal_character.connect(sigc::mem_fun(this, &Root::character_event)); + if(mouse) + { + mouse->signal_button_press.connect(sigc::mem_fun(this, &Root::button_press_event)); + mouse->signal_button_release.connect(sigc::mem_fun(this, &Root::button_release_event)); + mouse->signal_axis_motion.connect(sigc::mem_fun(this, &Root::axis_motion_event)); + } + + if(keyboard) + { + keyboard->signal_button_press.connect(sigc::mem_fun(this, &Root::key_press_event)); + keyboard->signal_button_release.connect(sigc::mem_fun(this, &Root::key_release_event)); + keyboard->signal_character.connect(sigc::mem_fun(this, &Root::character_event)); + } } Root::~Root()