]> git.tdb.fi Git - libs/gltk.git/commitdiff
Guard against null pointers
authorMikko Rasa <tdb@tdb.fi>
Sun, 24 Mar 2013 15:32:01 +0000 (17:32 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 24 Mar 2013 15:32:01 +0000 (17:32 +0200)
source/root.cpp

index 1dea150966a943b2093189fb4c90bc01f05334e8..1b47e8a0ff3843fb645d5ef6abffdb076b62de8f 100644 (file)
@@ -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()