Add an interceptor for GTK error messages to hide them
wxWidgets seems to cause GTK to spam messages to the terminal, and we have no control over that. So lets hide the messages so no one complains about them. If people really want to see them, they can add the KICAD_SHOW_GTK_MESSAGES build flag to CMake and they can watch them scroll past.
This commit is contained in:
parent
3036683a2c
commit
008f0d55c3
|
@ -1,3 +1,11 @@
|
||||||
|
option( KICAD_SHOW_GTK_MESSAGES
|
||||||
|
"Show all the GTK error messages in the terminal"
|
||||||
|
OFF )
|
||||||
|
|
||||||
|
mark_as_advanced( KICAD_SHOW_GTK_MESSAGES )
|
||||||
|
|
||||||
|
set( PLATFORM_COMPILE_DEFS "" )
|
||||||
|
|
||||||
# Add the appropriate source files
|
# Add the appropriate source files
|
||||||
if( APPLE )
|
if( APPLE )
|
||||||
set( PLATFORM_SRCS
|
set( PLATFORM_SRCS
|
||||||
|
@ -40,6 +48,13 @@ elseif( UNIX )
|
||||||
include_directories( SYSTEM ${GTK3_INCLUDE_DIRS} )
|
include_directories( SYSTEM ${GTK3_INCLUDE_DIRS} )
|
||||||
link_directories( ${GTK3_LIBRARY_DIRS} )
|
link_directories( ${GTK3_LIBRARY_DIRS} )
|
||||||
add_definitions( ${GTK3_CFLAGS_OTHER} )
|
add_definitions( ${GTK3_CFLAGS_OTHER} )
|
||||||
|
|
||||||
|
# Add the definition to show the GTK error messages if desired (they are hidden
|
||||||
|
# by us by default)
|
||||||
|
if( KICAD_SHOW_GTK_MESSAGES )
|
||||||
|
message( STATUS "Configuring KiCad not to hide any GTK error messages" )
|
||||||
|
string( APPEND PLATFORM_COMPILE_DEFS "-DKICAD_SHOW_GTK_MESSAGES" )
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +62,10 @@ add_library( kiplatform STATIC
|
||||||
${PLATFORM_SRCS}
|
${PLATFORM_SRCS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_compile_definitions( kiplatform PRIVATE
|
||||||
|
${PLATFORM_COMPILE_DEFS}
|
||||||
|
)
|
||||||
|
|
||||||
target_include_directories( kiplatform PUBLIC
|
target_include_directories( kiplatform PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,10 +20,23 @@
|
||||||
|
|
||||||
#include <kiplatform/app.h>
|
#include <kiplatform/app.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <wx/utils.h>
|
#include <wx/utils.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function to attach to the glib logger to eat the output it gives so we don't
|
||||||
|
* get the message spam on the terminal from wxWidget's abuse of the GTK API.
|
||||||
|
*/
|
||||||
|
static GLogWriterOutput nullLogWriter( GLogLevelFlags log_level, const GLogField* fields,
|
||||||
|
gsize n_fields, gpointer user_data )
|
||||||
|
{
|
||||||
|
return G_LOG_WRITER_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KIPLATFORM::APP::PlatformInit()
|
bool KIPLATFORM::APP::PlatformInit()
|
||||||
{
|
{
|
||||||
// Disable proxy menu in Unity window manager. Only usual menubar works with
|
// Disable proxy menu in Unity window manager. Only usual menubar works with
|
||||||
|
@ -47,9 +60,15 @@ bool KIPLATFORM::APP::PlatformInit()
|
||||||
// events.
|
// events.
|
||||||
wxSetEnv( wxT( "GDK_CORE_DEVICE_EVENTS" ), wxT( "1" ) );
|
wxSetEnv( wxT( "GDK_CORE_DEVICE_EVENTS" ), wxT( "1" ) );
|
||||||
|
|
||||||
|
#if !defined( KICAD_SHOW_GTK_MESSAGES )
|
||||||
|
// Attach a logger that will consume the annoying GTK error messages
|
||||||
|
g_log_set_writer_func( nullLogWriter, NULL, NULL );
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
|
bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
|
||||||
{
|
{
|
||||||
// Not implemented on this platform
|
// Not implemented on this platform
|
||||||
|
|
Loading…
Reference in New Issue