forked from bartvdbraak/blender
GHOST: Only spam about X11 errors when using --debug-ghost
This commit adds a new command line argument --debug-ghost and makes it so X11 errors happening during context initialization are only printed when this new flag is sued. There is no need to flood users with errors when their GPU is not supporting latest OpenGL version. Or, at a very minimum, the error must be more meaning full. Differential Revision: https://developer.blender.org/D6057
This commit is contained in:
parent
dc8be23234
commit
8d4460b6c4
@ -58,6 +58,11 @@ typedef int (*GHOST_EventCallbackProcPtr)(GHOST_EventHandle event, GHOST_TUserDa
|
||||
*/
|
||||
extern GHOST_SystemHandle GHOST_CreateSystem(void);
|
||||
|
||||
/**
|
||||
* Specifies whether debug messages are to be enabled for the specific system handle.
|
||||
*/
|
||||
extern void GHOST_SystemInitDebug(GHOST_SystemHandle systemhandle, int is_debug_enabled);
|
||||
|
||||
/**
|
||||
* Disposes the one and only system.
|
||||
* \param systemhandle The handle to the system
|
||||
|
@ -458,6 +458,20 @@ class GHOST_ISystem {
|
||||
const char * /*link*/,
|
||||
GHOST_DialogOptions /*dialog_options*/) const = 0;
|
||||
|
||||
/***************************************************************************************
|
||||
* Debugging
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* Specify whether debug messages are to be shown.
|
||||
*/
|
||||
virtual void initDebug(bool is_debug_enabled) = 0;
|
||||
|
||||
/**
|
||||
* Check whether debug messages are to be shown.
|
||||
*/
|
||||
virtual bool isDebugEnabled() = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Initialize the system.
|
||||
|
@ -40,6 +40,13 @@ GHOST_SystemHandle GHOST_CreateSystem(void)
|
||||
return (GHOST_SystemHandle)system;
|
||||
}
|
||||
|
||||
void GHOST_SystemInitDebug(GHOST_SystemHandle systemhandle, int is_debug_enabled)
|
||||
{
|
||||
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
|
||||
|
||||
system->initDebug(is_debug_enabled);
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle)
|
||||
{
|
||||
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
|
||||
|
@ -46,7 +46,8 @@ GHOST_System::GHOST_System()
|
||||
#ifdef WITH_INPUT_NDOF
|
||||
m_ndofManager(0),
|
||||
#endif
|
||||
m_tabletAPI(GHOST_kTabletAutomatic)
|
||||
m_tabletAPI(GHOST_kTabletAutomatic),
|
||||
m_is_debug_enabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -388,3 +389,13 @@ void GHOST_System::useWindowFocus(const bool use_focus)
|
||||
{
|
||||
m_windowFocus = use_focus;
|
||||
}
|
||||
|
||||
void GHOST_System::initDebug(bool is_debug_enabled)
|
||||
{
|
||||
m_is_debug_enabled = is_debug_enabled;
|
||||
}
|
||||
|
||||
bool GHOST_System::isDebugEnabled()
|
||||
{
|
||||
return m_is_debug_enabled;
|
||||
}
|
||||
|
@ -328,6 +328,20 @@ class GHOST_System : public GHOST_ISystem {
|
||||
return GHOST_kFailure;
|
||||
};
|
||||
|
||||
/***************************************************************************************
|
||||
* Debugging
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* Specify whether debug messages are to be shown.
|
||||
*/
|
||||
virtual void initDebug(bool is_debug_enabled);
|
||||
|
||||
/**
|
||||
* Check whether debug messages are to be shown.
|
||||
*/
|
||||
virtual bool isDebugEnabled();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Initialize the system.
|
||||
@ -378,6 +392,8 @@ class GHOST_System : public GHOST_ISystem {
|
||||
|
||||
/** Which tablet API to use. */
|
||||
GHOST_TTabletAPI m_tabletAPI;
|
||||
|
||||
bool m_is_debug_enabled;
|
||||
};
|
||||
|
||||
inline GHOST_TimerManager *GHOST_System::getTimerManager() const
|
||||
|
@ -2383,6 +2383,11 @@ GHOST_TSuccess GHOST_SystemX11::pushDragDropEvent(GHOST_TEventType eventType,
|
||||
*/
|
||||
int GHOST_X11_ApplicationErrorHandler(Display *display, XErrorEvent *event)
|
||||
{
|
||||
GHOST_ISystem *system = GHOST_ISystem::getSystem();
|
||||
if (!system->isDebugEnabled()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char error_code_str[512];
|
||||
|
||||
XGetErrorText(display, event->error_code, error_code_str, sizeof(error_code_str));
|
||||
@ -2404,6 +2409,11 @@ int GHOST_X11_ApplicationErrorHandler(Display *display, XErrorEvent *event)
|
||||
|
||||
int GHOST_X11_ApplicationIOErrorHandler(Display * /*display*/)
|
||||
{
|
||||
GHOST_ISystem *system = GHOST_ISystem::getSystem();
|
||||
if (!system->isDebugEnabled()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Ignoring Xlib error: error IO\n");
|
||||
|
||||
/* No exit! - but keep lint happy */
|
||||
|
@ -151,11 +151,14 @@ enum {
|
||||
G_DEBUG_IO = (1 << 17), /* IO Debugging (for Collada, ...)*/
|
||||
G_DEBUG_GPU_SHADERS = (1 << 18), /* GLSL shaders */
|
||||
G_DEBUG_GPU_FORCE_WORKAROUNDS = (1 << 19), /* force gpu workarounds bypassing detections. */
|
||||
|
||||
G_DEBUG_GHOST = (1 << 20), /* Debug GHOST module. */
|
||||
};
|
||||
|
||||
#define G_DEBUG_ALL \
|
||||
(G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS | \
|
||||
G_DEBUG_FREESTYLE | G_DEBUG_DEPSGRAPH | G_DEBUG_GPU_MEM | G_DEBUG_IO | G_DEBUG_GPU_SHADERS)
|
||||
G_DEBUG_FREESTYLE | G_DEBUG_DEPSGRAPH | G_DEBUG_GPU_MEM | G_DEBUG_IO | G_DEBUG_GPU_SHADERS | \
|
||||
G_DEBUG_GHOST)
|
||||
|
||||
/** #Global.fileflags */
|
||||
enum {
|
||||
|
@ -1638,6 +1638,7 @@ void wm_ghost_init(bContext *C)
|
||||
}
|
||||
|
||||
g_system = GHOST_CreateSystem();
|
||||
GHOST_SystemInitDebug(g_system, G.debug & G_DEBUG_GHOST);
|
||||
|
||||
if (C != NULL) {
|
||||
GHOST_AddEventConsumer(g_system, consumer);
|
||||
|
@ -2079,6 +2079,12 @@ void main_args_setup(bContext *C, bArgs *ba)
|
||||
(void *)G_DEBUG_HANDLERS);
|
||||
BLI_argsAdd(
|
||||
ba, 1, NULL, "--debug-wm", CB_EX(arg_handle_debug_mode_generic_set, wm), (void *)G_DEBUG_WM);
|
||||
BLI_argsAdd(ba,
|
||||
1,
|
||||
NULL,
|
||||
"--debug-ghost",
|
||||
CB_EX(arg_handle_debug_mode_generic_set, handlers),
|
||||
(void *)G_DEBUG_GHOST);
|
||||
BLI_argsAdd(ba, 1, NULL, "--debug-all", CB(arg_handle_debug_mode_all), NULL);
|
||||
|
||||
BLI_argsAdd(ba, 1, NULL, "--debug-io", CB(arg_handle_debug_mode_io), NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user