From 6ba9a24a2c0e7e70deca4aff9d24fcbccacb6d12 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 17 May 2013 08:01:39 +0000 Subject: [PATCH] API to get message handler + never intiialize twice --- CMakeLists.txt | 5 ++++- Common/Gmsh.cpp | 9 +++++++++ Common/Gmsh.h | 1 + Common/GmshMessage.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f7d1c1225..5508629bc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -472,7 +472,7 @@ endif(ENABLE_BUILD_ANDROID) if(HAVE_FLTK OR HAVE_QT OR ENABLE_GRAPHICS) if(NOT HAVE_MESH OR NOT HAVE_POST OR NOT HAVE_PLUGINS OR NOT HAVE_ONELAB) - message(SEND_ERROR "Cannot compile GUI without Mesh, Post, Plugin or OneLab") + message(SEND_ERROR "Cannot compile GUI without Mesh, Post, Plugin and OneLab") endif(NOT HAVE_MESH OR NOT HAVE_POST OR NOT HAVE_PLUGINS OR NOT HAVE_ONELAB) if(FLTK_JPEG) @@ -1281,6 +1281,9 @@ if(ENABLE_BUILD_LIB) endif(ENABLE_BUILD_LIB) if(ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC) install(TARGETS shared DESTINATION ${GMSH_LIB} OPTIONAL) + if(WIN32 OR CYGWIN) + + endif(WIN32 OR CYGWIN) endif(ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC) install(FILES ${ONELAB_PY} DESTINATION ${GMSH_BIN}) diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp index f5d761d952..fb8a33bd4b 100644 --- a/Common/Gmsh.cpp +++ b/Common/Gmsh.cpp @@ -45,6 +45,10 @@ int GmshInitialize(int argc, char **argv) { + static bool isInitialized = false; + if(isInitialized) return 1; + isInitialized = true; + #if defined(HAVE_FLTK) RedirectIOToConsole(); #endif @@ -83,6 +87,11 @@ int GmshSetMessageHandler(GmshMessage *callback) return 1; } +GmshMessage *GmshGetMessageHandler() +{ + return Msg::GetCallback(); +} + int GmshSetBoundingBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) diff --git a/Common/Gmsh.h b/Common/Gmsh.h index 28e7f05667..833cfe7f67 100644 --- a/Common/Gmsh.h +++ b/Common/Gmsh.h @@ -11,6 +11,7 @@ int GmshInitialize(int argc=0, char **argv=0); int GmshSetMessageHandler(GmshMessage *callback); +GmshMessage *GmshGetMessageHandler(); int GmshSetBoundingBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax); diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index e44f310175..d4b3c6f11f 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -56,6 +56,7 @@ class Msg { static void SetCommRank(int val){ _commRank = val; } static void SetCommSize(int val){ _commSize = val; } static void SetCallback(GmshMessage *callback){ _callback = callback; } + static GmshMessage *GetCallback(){ return _callback; } static void Barrier(); static int GetNumThreads(); static int GetMaxThreads(); -- GitLab