forked from enlightenment/efl
ecore-x: Add safety checks for NULL display in dpms functions
xlib immediately crashes upon being passed a NULL display object, so every function in ecore-x should likely have safety checks such as these. @fix Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
This commit is contained in:
parent
21a2a8007d
commit
2be9bfc2a8
|
@ -12,6 +12,8 @@ _ecore_x_dpms_init(void)
|
|||
#ifdef ECORE_XDPMS
|
||||
int _dpms_major, _dpms_minor;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
|
||||
_dpms_major = 1;
|
||||
_dpms_minor = 0;
|
||||
|
||||
|
@ -53,6 +55,7 @@ ecore_x_dpms_capable_get(void)
|
|||
{
|
||||
#ifdef ECORE_XDPMS
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
return DPMSCapable(_ecore_x_disp) ? EINA_TRUE : EINA_FALSE;
|
||||
#else /* ifdef ECORE_XDPMS */
|
||||
return EINA_FALSE;
|
||||
|
@ -72,6 +75,7 @@ ecore_x_dpms_enabled_get(void)
|
|||
unsigned short power_lvl;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
DPMSInfo(_ecore_x_disp, &power_lvl, &state);
|
||||
return state ? EINA_TRUE : EINA_FALSE;
|
||||
#else /* ifdef ECORE_XDPMS */
|
||||
|
@ -96,6 +100,7 @@ ecore_x_dpms_power_level_get(void)
|
|||
unsigned short power_lvl;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, -1);
|
||||
DPMSInfo(_ecore_x_disp, &power_lvl, &state);
|
||||
return (int)power_lvl;
|
||||
#else
|
||||
|
@ -113,6 +118,7 @@ ecore_x_dpms_enabled_set(int enabled)
|
|||
{
|
||||
#ifdef ECORE_XDPMS
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
if (enabled)
|
||||
DPMSEnable(_ecore_x_disp);
|
||||
else
|
||||
|
@ -135,6 +141,7 @@ ecore_x_dpms_timeouts_get(unsigned int *standby,
|
|||
{
|
||||
#ifdef ECORE_XDPMS
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
DPMSGetTimeouts(_ecore_x_disp, (unsigned short *)standby,
|
||||
(unsigned short *)suspend, (unsigned short *)off);
|
||||
#endif /* ifdef ECORE_XDPMS */
|
||||
|
@ -154,6 +161,7 @@ ecore_x_dpms_timeouts_set(unsigned int standby,
|
|||
{
|
||||
#ifdef ECORE_XDPMS
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
return DPMSSetTimeouts(_ecore_x_disp, standby, suspend, off) ? EINA_TRUE : EINA_FALSE;
|
||||
#else /* ifdef ECORE_XDPMS */
|
||||
return EINA_FALSE;
|
||||
|
@ -172,6 +180,7 @@ ecore_x_dpms_timeout_standby_get(void)
|
|||
unsigned short standby, suspend, off;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
|
||||
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
|
||||
return standby;
|
||||
#else /* ifdef ECORE_XDPMS */
|
||||
|
@ -192,6 +201,7 @@ ecore_x_dpms_timeout_suspend_get(void)
|
|||
unsigned short standby, suspend, off;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
|
||||
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
|
||||
return suspend;
|
||||
#else /* ifdef ECORE_XDPMS */
|
||||
|
@ -212,6 +222,7 @@ ecore_x_dpms_timeout_off_get(void)
|
|||
unsigned short standby, suspend, off;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
|
||||
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
|
||||
return off;
|
||||
#else /* ifdef ECORE_XDPMS */
|
||||
|
@ -231,6 +242,7 @@ ecore_x_dpms_timeout_standby_set(unsigned int new_timeout)
|
|||
unsigned short standby, suspend, off;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
|
||||
DPMSSetTimeouts(_ecore_x_disp, new_timeout, suspend, off);
|
||||
#endif /* ifdef ECORE_XDPMS */
|
||||
|
@ -248,6 +260,7 @@ ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout)
|
|||
unsigned short standby, suspend, off;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
|
||||
DPMSSetTimeouts(_ecore_x_disp, standby, new_timeout, off);
|
||||
#endif /* ifdef ECORE_XDPMS */
|
||||
|
@ -265,8 +278,8 @@ ecore_x_dpms_timeout_off_set(unsigned int new_timeout)
|
|||
unsigned short standby, suspend, off;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
|
||||
DPMSSetTimeouts(_ecore_x_disp, standby, suspend, new_timeout);
|
||||
#endif /* ifdef ECORE_XDPMS */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue