From 66f63cae4e41c6b62ce6657bfc7cd9c8309836ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Krzysztof=20Kosi=C5=84ski?= Date: Wed, 20 Jan 2010 20:31:57 +0100 Subject: [PATCH] Go back to using TR1 unordered containers to fix warnings. Add configure code to detect the broken header and display Wiki page URL. --- configure.ac | 21 +++++++++++++++++++-- src/libnrtype/FontFactory.cpp | 14 +++++++------- src/libnrtype/FontInstance.cpp | 8 ++------ src/libnrtype/font-instance.h | 4 ++-- src/ui/tool/control-point-selection.h | 22 ++++------------------ src/ui/tool/multi-path-manipulator.cpp | 18 ++++-------------- src/ui/tool/node.cpp | 2 +- src/util/hash.h | 6 ++++-- 8 files changed, 43 insertions(+), 52 deletions(-) diff --git a/configure.ac b/configure.ac index 5dac99d08..fde3120c6 100644 --- a/configure.ac +++ b/configure.ac @@ -675,8 +675,8 @@ AM_CONDITIONAL(HAVE_CARBON, test "x$carbon_ok" = "xyes") # Check for some boost header files AC_CHECK_HEADERS([boost/concept_check.hpp], [], AC_MSG_ERROR([You need the boost package (e.g. libboost-dev)])) -# test whether GCC emits a spurious warning when using boost::optional -# if yes, turn off strict aliasing warnings +# Test whether GCC emits a spurious warning when using boost::optional +# If yes, turn off strict aliasing warnings to reduce noise AC_MSG_CHECKING([for overzealous strict aliasing warnings]) ignore_strict_aliasing=no CXXFLAGS_SAVE=$CXXFLAGS @@ -694,6 +694,23 @@ if test "x$ignore_strict_aliasing" = "xyes"; then CXXFLAGS="$CXXFLAGS -Wno-strict-aliasing" fi +# Test for broken unordered_set on GCC 4.0.0, shipped with Apple XCode tools +AC_MSG_CHECKING([TR1 unordered_set usability]) +AC_COMPILE_IFELSE([ +#include +int main() { + std::tr1::unordered_set i, j; + i = j; + return 0; +} +], [unordered_set_broken=no], [unordered_set_broken=yes]) +if test "x$unordered_set_broken" = "xyes"; then + AC_MSG_RESULT([broken]) + AC_MSG_ERROR([You have a broken version of the header. See http://wiki.inkscape.org/wiki/index.php/CompilingMacOsX for information on how to fix this problem.]) +else + AC_MSG_RESULT([ok]) +fi + PKG_CHECK_MODULES(CAIRO_PDF, cairo-pdf, cairo_pdf=yes, cairo_pdf=no) if test "x$cairo_pdf" = "xyes"; then AC_DEFINE(HAVE_CAIRO_PDF, 1, [Whether the Cairo PDF backend is available]) diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 761da7756..09d9e2c4f 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -26,11 +26,9 @@ /* Freetype2 */ # include -//#include -#include +#include - -typedef __gnu_cxx::hash_map FaceMapType; +typedef std::tr1::unordered_map FaceMapType; // need to avoid using the size field size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { @@ -826,9 +824,11 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) if ( nFace ) { // duplicate FcPattern, the hard way res = new font_instance(); - // store the descr of the font we asked for, since this is the key where we intend to put the font_instance at - // in the hash_map. the descr of the returned pangofont may differ from what was asked, so we don't know (at this - // point) whether loadedFaces[that_descr] is free or not (and overwriting an entry will bring deallocation problems) + // store the descr of the font we asked for, since this is the key where we intend + // to put the font_instance at in the unordered_map. the descr of the returned + // pangofont may differ from what was asked, so we don't know (at this + // point) whether loadedFaces[that_descr] is free or not (and overwriting + // an entry will bring deallocation problems) res->descr = pango_font_description_copy(descr); res->daddy = this; res->InstallFace(nFace); diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 8b8eb8bbe..628e3cba0 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -29,12 +29,9 @@ # include FT_TRUETYPE_TABLES_H # include -//#include -#include +#include -// the various raster_font in use at a given time are held in a hash_map whose indices are the -// styles, hence the 2 following 'classes' struct font_style_hash : public std::unary_function { size_t operator()(font_style const &x) const; }; @@ -43,8 +40,7 @@ struct font_style_equal : public std::binary_function StyleMap; +typedef std::tr1::unordered_map StyleMap; diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index 521c9a424..d52bd723f 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -25,7 +25,7 @@ public: // depending on the rendering backend, different temporary data // that's the font's fingerprint; this particular PangoFontDescription gives the entry at which this font_instance - // resides in the font_factory loadedFaces hash_map + // resides in the font_factory loadedFaces unordered_map PangoFontDescription* descr; // refcount int refCount; @@ -86,7 +86,7 @@ private: void FreeTheFace(); // hashmap to get the raster_font for a given style - void* loadedPtr; // Pointer to a hash_map. Moved into .cpp to not expose use of __gnu_cxx extension. + void* loadedPtr; #ifdef USE_PANGO_WIN32 HFONT theFace; diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h index dce685575..54d724f00 100644 --- a/src/ui/tool/control-point-selection.h +++ b/src/ui/tool/control-point-selection.h @@ -13,11 +13,8 @@ #define SEEN_UI_TOOL_NODE_SELECTION_H #include -// those are broken beyond hope on OSX. -//#include -//#include -#include -#include +#include +#include #include #include #include @@ -30,8 +27,6 @@ #include "ui/tool/commit-events.h" #include "ui/tool/manipulator.h" -namespace std { using namespace __gnu_cxx; } - class SPDesktop; namespace Inkscape { @@ -41,15 +36,6 @@ class SelectableControlPoint; } } -namespace __gnu_cxx { -template<> -struct hash { - size_t operator()(Inkscape::UI::SelectableControlPoint *p) const { - return reinterpret_cast(p); - } -}; -} // namespace __gnu_cxx - namespace Inkscape { namespace UI { @@ -58,9 +44,9 @@ public: ControlPointSelection(SPDesktop *d, SPCanvasGroup *th_group); ~ControlPointSelection(); typedef std::list connlist_type; - typedef std::hash_map< SelectableControlPoint *, + typedef std::tr1::unordered_map< SelectableControlPoint *, boost::shared_ptr > map_type; - typedef std::hash_set< SelectableControlPoint * > set_type; + typedef std::tr1::unordered_set< SelectableControlPoint * > set_type; typedef set_type Set; // convenience alias typedef map_type::iterator iterator; diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index c05b71cd4..d1138abd5 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -1,5 +1,5 @@ /** @file - * Path manipulator - implementation + * Multi path manipulator - implementation */ /* Authors: * Krzysztof Kosiński @@ -8,8 +8,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -//#include -#include +#include #include #include #include @@ -26,16 +25,7 @@ #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/path-manipulator.h" -namespace std { using namespace __gnu_cxx; } - -namespace __gnu_cxx { -template<> -struct hash { - size_t operator()(Inkscape::UI::NodeList::iterator const &n) const { - return reinterpret_cast(n.ptr()); - } -}; -} +namespace std { using namespace tr1; } namespace Inkscape { namespace UI { @@ -43,7 +33,7 @@ namespace UI { namespace { typedef std::pair IterPair; typedef std::vector IterPairList; -typedef std::hash_set IterSet; +typedef std::unordered_set IterSet; typedef std::multimap DistanceMap; typedef std::pair DistanceMapItem; diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index c1dfcdeaa..ef98e7c84 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -955,7 +955,7 @@ Glib::ustring Node::_getTip(unsigned state) if (state_held_control(state)) { if (state_held_alt(state)) { - return C_("Path node tip", "Ctrl+Alt: move along handle lines"); + return C_("Path node tip", "Ctrl+Alt: move along handle lines, click to delete node"); } return C_("Path node tip", "Ctrl: move along axes, click to change node type"); diff --git a/src/util/hash.h b/src/util/hash.h index 33af9222d..d5abeff5a 100644 --- a/src/util/hash.h +++ b/src/util/hash.h @@ -13,7 +13,8 @@ #include -namespace __gnu_cxx { +namespace std { +namespace tr1 { /** Hash function for Boost shared pointers */ template @@ -23,7 +24,8 @@ struct hash< boost::shared_ptr > : public std::unary_function