Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-10-14 13:44:41 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-11-18 11:28:17 +0300
commit8d4460b6c4b4406a3dc873b820dbe94d74437a46 (patch)
treed5c09873046d5a5c92199b19cdc9ae61bc4de6f9
parentdc8be23234a86186d9768b47ffcce9d801d6bae7 (diff)
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
-rw-r--r--intern/ghost/GHOST_C-api.h5
-rw-r--r--intern/ghost/GHOST_ISystem.h14
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp7
-rw-r--r--intern/ghost/intern/GHOST_System.cpp13
-rw-r--r--intern/ghost/intern/GHOST_System.h16
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp10
-rw-r--r--source/blender/blenkernel/BKE_global.h5
-rw-r--r--source/blender/windowmanager/intern/wm_window.c1
-rw-r--r--source/creator/creator_args.c6
9 files changed, 75 insertions, 2 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 720929ce945..ba46a868df6 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -59,6 +59,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
* \return An indication of success.
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index b781de266bc..4634eb1bc66 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -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.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index eeb23ea7471..1bed7afdfc4 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -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;
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index 21935abed9c..fc9ce1f66e1 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -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;
+}
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 893592e3cf5..26b566e6b7e 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -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
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index cb2a04a8a87..72c0ad761a4 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -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 */
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index bee76c09cbc..65c3725d994 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -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 {
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 937cc8e7467..7a5f4bf8367 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -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);
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 936bdf52c91..6e3988a5ea6 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -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);