|
From: <br...@us...> - 2010-05-27 16:25:44
|
Revision: 4147
http://openvrml.svn.sourceforge.net/openvrml/?rev=4147&view=rev
Author: braden
Date: 2010-05-27 16:25:37 +0000 (Thu, 27 May 2010)
Log Message:
-----------
FcFini cannot be called safely from library code. Calling it is not a strict requirement; though it does clean up valgrind results. To this end, call it from sdl-viewer instead.
Modified Paths:
--------------
trunk/ChangeLog
trunk/examples/Makefile.am
trunk/examples/sdl_viewer.cpp
trunk/src/node/vrml97/text.cpp
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-05-27 14:53:03 UTC (rev 4146)
+++ trunk/ChangeLog 2010-05-27 16:25:37 UTC (rev 4147)
@@ -1,5 +1,23 @@
2010-05-27 Braden McDaniel <br...@en...>
+ FcFini cannot be called safely from library code. Calling it is
+ not a strict requirement; though it does clean up valgrind
+ results. To this end, call it from sdl-viewer instead.
+
+ * examples/Makefile.am
+ (sdl_viewer_CXXFLAGS): Add FONTCONFIG_CFLAGS.
+ (sdl_viewer_LDFLAGS): Add FONTCONFIG_LIBS.
+ * examples/sdl_viewer.cpp
+ (main(int, char *[])): Call FcFini on shutdown if built with
+ OPENVRML_ENABLE_RENDER_TEXT_NODE.
+ * src/node/vrml97/text.cpp
+ (openvrml_node_vrml97::text_metatype::text_metatype(openvrml::browser&)):
+ It's safe to call FcInit redundantly.
+ (openvrml_node_vrml97::text_metatype::~text_metatype()): Don't
+ call FcFini from library code.
+
+2010-05-27 Braden McDaniel <br...@en...>
+
Call FcInit/FcFini to clean up resources used by Fontconfig.
* src/node/vrml97/text.cpp
Modified: trunk/examples/Makefile.am
===================================================================
--- trunk/examples/Makefile.am 2010-05-27 14:53:03 UTC (rev 4146)
+++ trunk/examples/Makefile.am 2010-05-27 16:25:37 UTC (rev 4147)
@@ -19,8 +19,8 @@
-I$(top_srcdir)/src/libopenvrml \
-I$(top_builddir)/src/libopenvrml-gl \
-I$(top_srcdir)/src/libopenvrml-gl
-sdl_viewer_CXXFLAGS = $(SDL_CFLAGS)
-sdl_viewer_LDFLAGS = $(SDL_LIBS) $(GLU_LIBS)
+sdl_viewer_CXXFLAGS = $(SDL_CFLAGS) $(FONTCONFIG_CFLAGS)
+sdl_viewer_LDFLAGS = $(SDL_LIBS) $(GLU_LIBS) $(FONTCONFIG_LIBS)
sdl_viewer_LDADD = $(top_builddir)/src/libopenvrml-gl/libopenvrml-gl.la
pretty_print_SOURCES = pretty_print.cpp
Modified: trunk/examples/sdl_viewer.cpp
===================================================================
--- trunk/examples/sdl_viewer.cpp 2010-05-27 14:53:03 UTC (rev 4146)
+++ trunk/examples/sdl_viewer.cpp 2010-05-27 16:25:37 UTC (rev 4147)
@@ -31,6 +31,8 @@
# include <openvrml/gl/viewer.h>
# ifdef _WIN32
# include <windows.h>
+# elif defined(OPENVRML_ENABLE_RENDER_TEXT_NODE)
+# include <fontconfig/fontconfig.h>
# endif
extern "C" Uint32 update_timer_callback(Uint32 interval, void * param);
@@ -115,6 +117,10 @@
return EXIT_FAILURE;
}
+# if defined(OPENVRML_ENABLE_RENDER_TEXT_NODE) && !defined(_WIN32)
+ FcFini();
+# endif
+
# ifdef _WIN32
fclose(out);
FreeConsole();
Modified: trunk/src/node/vrml97/text.cpp
===================================================================
--- trunk/src/node/vrml97/text.cpp 2010-05-27 14:53:03 UTC (rev 4146)
+++ trunk/src/node/vrml97/text.cpp 2010-05-27 16:25:37 UTC (rev 4147)
@@ -2752,15 +2752,6 @@
* @see http://freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Library
*/
-namespace {
- //
- // We need to call FcFini once (and only once) when we're finished with
- // the library (i.e., shutdown).
- //
- OPENVRML_LOCAL size_t fc_use_count = 0;
- OPENVRML_LOCAL boost::mutex fc_use_count_mutex;
-}
-
/**
* @brief Construct.
*
@@ -2771,17 +2762,9 @@
node_metatype(text_metatype::id, browser)
{
# ifdef OPENVRML_ENABLE_RENDER_TEXT_NODE
- {
- using boost::mutex;
- using boost::unique_lock;
-
- unique_lock<mutex> lock(fc_use_count_mutex);
- if (fc_use_count++ == 0) {
- FcBool fc_succeeded = FcInit();
- if (!fc_succeeded) {
- browser.err("error initializing fontconfig library");
- }
- }
+ FcBool fc_succeeded = FcInit();
+ if (!fc_succeeded) {
+ browser.err("error initializing fontconfig library");
}
FT_Error ft_error = 0;
@@ -2802,12 +2785,6 @@
if (ft_error) {
this->browser().err("error shutting down FreeType library");
}
-
- using boost::mutex;
- using boost::unique_lock;
-
- unique_lock<mutex> lock(fc_use_count_mutex);
- if (--fc_use_count == 0) { FcFini(); }
# endif // OPENVRML_ENABLE_RENDER_TEXT_NODE
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|