From a6ad80d9e852bb47e435915d9d491819d0947016 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 Oct 2019 10:13:17 +0200 Subject: Fix T70125: crash on startup in Linux with some tablet types connected --- intern/ghost/intern/GHOST_SystemX11.cpp | 38 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index e46edeeac9a..639553f31bb 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -2303,26 +2303,30 @@ void GHOST_SystemX11::refreshXInputDevices() /* Find how many pressure levels tablet has */ XAnyClassPtr ici = device_info[i].inputclassinfo; - for (int j = 0; j < xtablet.Device->num_classes; ++j) { - if (ici->c_class == ValuatorClass) { - XValuatorInfo *xvi = (XValuatorInfo *)ici; - xtablet.PressureLevels = xvi->axes[2].max_value; - - if (xvi->num_axes > 3) { - /* this is assuming that the tablet has the same tilt resolution in both - * positive and negative directions. It would be rather weird if it didn't.. */ - xtablet.XtiltLevels = xvi->axes[3].max_value; - xtablet.YtiltLevels = xvi->axes[4].max_value; - } - else { - xtablet.XtiltLevels = 0; - xtablet.YtiltLevels = 0; + if (ici != NULL) { + for (int j = 0; j < xtablet.Device->num_classes; ++j) { + if (ici->c_class == ValuatorClass) { + XValuatorInfo *xvi = (XValuatorInfo *)ici; + if (xvi->axes != NULL) { + xtablet.PressureLevels = xvi->axes[2].max_value; + + if (xvi->num_axes > 3) { + /* this is assuming that the tablet has the same tilt resolution in both + * positive and negative directions. It would be rather weird if it didn't.. */ + xtablet.XtiltLevels = xvi->axes[3].max_value; + xtablet.YtiltLevels = xvi->axes[4].max_value; + } + else { + xtablet.XtiltLevels = 0; + xtablet.YtiltLevels = 0; + } + + break; + } } - break; + ici = (XAnyClassPtr)(((char *)ici) + ici->length); } - - ici = (XAnyClassPtr)(((char *)ici) + ici->length); } m_xtablets.push_back(xtablet); -- cgit v1.2.3