vbox: avoid null access in input handling

that happened during early bootup.

The signal about input events may arrive before keyboard and mouse is set
(due wait_and_dispatch_one_signal called from a started pthread and ep still
 not done with the initialisation)

Issue #2306
This commit is contained in:
Alexander Boettcher 2017-02-28 17:36:48 +01:00 committed by Christian Helmuth
parent 34d1b60f52
commit af3c238ce1
2 changed files with 18 additions and 6 deletions

View File

@ -186,11 +186,17 @@ void GenodeConsole::handle_input()
/* read out input capabilities of guest */
bool guest_abs = false, guest_rel = false, guest_multi = false;
_vbox_mouse->COMGETTER(AbsoluteSupported)(&guest_abs);
_vbox_mouse->COMGETTER(RelativeSupported)(&guest_rel);
_vbox_mouse->COMGETTER(MultiTouchSupported)(&guest_multi);
if (_vbox_mouse) {
_vbox_mouse->COMGETTER(AbsoluteSupported)(&guest_abs);
_vbox_mouse->COMGETTER(RelativeSupported)(&guest_rel);
_vbox_mouse->COMGETTER(MultiTouchSupported)(&guest_multi);
}
_input.for_each_event([&] (Input::Event const &ev) {
/* if keyboard/mouse not available, consume input events and drop it */
if (!_vbox_keyboard || !_vbox_mouse)
return;
bool const press = ev.type() == Input::Event::PRESS;
bool const release = ev.type() == Input::Event::RELEASE;
bool const key = press || release;

View File

@ -131,11 +131,17 @@ void GenodeConsole::handle_input()
/* read out input capabilities of guest */
bool guest_abs = false, guest_rel = false, guest_multi = false;
_vbox_mouse->COMGETTER(AbsoluteSupported)(&guest_abs);
_vbox_mouse->COMGETTER(RelativeSupported)(&guest_rel);
_vbox_mouse->COMGETTER(MultiTouchSupported)(&guest_multi);
if (_vbox_mouse) {
_vbox_mouse->COMGETTER(AbsoluteSupported)(&guest_abs);
_vbox_mouse->COMGETTER(RelativeSupported)(&guest_rel);
_vbox_mouse->COMGETTER(MultiTouchSupported)(&guest_multi);
}
_input.for_each_event([&] (Input::Event const &ev) {
/* if keyboard/mouse not available, consume input events and drop it */
if (!_vbox_keyboard || !_vbox_mouse)
return;
bool const press = ev.type() == Input::Event::PRESS;
bool const release = ev.type() == Input::Event::RELEASE;
bool const key = press || release;