From: dooglus Date: Mon, 28 Jan 2008 14:23:41 +0000 (+0000) Subject: Revision 1494 introduced a bug in the bline tool. Dragging a tangent while drawing... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e5a5ede2bc37353016f6c3530234f827eccf538e;p=synfig.git Revision 1494 introduced a bug in the bline tool. Dragging a tangent while drawing would only show one tangent duck, not two. This was caused by the hash class no hashing the characters pointed to by a char*, but hashing the pointer itself now. See the first mention of 'char*' in open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1456.html . git-svn-id: http://svn.voria.com/code@1516 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/configure.ac b/synfig-core/trunk/configure.ac index 2af0216..45c00c0 100644 --- a/synfig-core/trunk/configure.ac +++ b/synfig-core/trunk/configure.ac @@ -456,12 +456,15 @@ AC_COMPILE_IFELSE([ AC_DEFINE([HASH_MAP_CLASS],[HASH_MAP_NAMESPACE::unordered_map],[The template name for unordered maps.]) AC_DEFINE([HASH_MAP_H],[],[The header file to include for unordered maps.]) AC_DEFINE([HASH_MAP_NAMESPACE],[std::tr1],[The namespace for unordered maps.]) + AC_DEFINE([FUNCTIONAL_H],[],[The header file for hash.]) + AC_DEFINE([FUNCTIONAL_HASH_ON_STRING],[1],[Define to 1 if hash needs to use T=String rather than T=char* to hash strings.]) ],[ AC_MSG_RESULT([no]) AC_CHECK_HEADERS([ext/hash_map],[ AC_DEFINE([HASH_MAP_CLASS],[HASH_MAP_NAMESPACE::hash_map],[The template name for unordered maps.]) AC_DEFINE([HASH_MAP_H],[],[The header file to include for unordered maps.]) AC_DEFINE([HASH_MAP_NAMESPACE],[__gnu_cxx],[The namespace for unordered maps.]) + AC_DEFINE([FUNCTIONAL_H],[],[The header file for hash.]) ],[ AC_MSG_ERROR([C++ compiler does not seem to support unordered containers]) ]) diff --git a/synfig-core/trunk/src/synfig/guid.cpp b/synfig-core/trunk/src/synfig/guid.cpp index ab4046b..d9c268b 100644 --- a/synfig-core/trunk/src/synfig/guid.cpp +++ b/synfig-core/trunk/src/synfig/guid.cpp @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -#define SUBTRACT_RNG_H - #ifdef USING_PCH # include "pch.h" #else @@ -47,11 +45,7 @@ #ifdef HASH_MAP_H #include HASH_MAP_H -#endif - -#ifdef SUBTRACT_RNG_H -#include SUBTRACT_RNG_H -using namespace __gnu_cxx; +#include FUNCTIONAL_H #endif #ifdef _WIN32 @@ -153,20 +147,31 @@ synfig::GUID synfig::GUID::hasher(const String& str) { #ifdef HASH_MAP_H + /* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1456.html says: + * + * "Some earlier hash table implementations gave char* special + * treatment: it specialized the default hash function to look + * at character array being pointed to, rather than the pointer + * itself. This proposal removes that special treatment." + * + * Unfortunately, the older implementation doesn't seem to want to + * accept Strings, so we're left with this conditional compilation. + */ +# ifdef FUNCTIONAL_HASH_ON_STRING + HASH_MAP_NAMESPACE::hash string_hash_; + const unsigned int seed(string_hash_(str)); +# else // FUNCTIONAL_HASH_ON_STRING HASH_MAP_NAMESPACE::hash string_hash_; - const unsigned int seed( - string_hash_( - str.c_str() - ) - ); -#else + const unsigned int seed(string_hash_(str.c_str())); +# endif // FUNCTIONAL_HASH_ON_STRING +#else // HASH_MAP_H unsigned int seed(0x3B642879); for(unsigned int i=0;i>(32-(i%24)))^(seed<<(i%24)); } -#endif +#endif // HASH_MAP_H GUID_RNG random(seed); GUID ret(0); diff --git a/synfig-studio/trunk/configure.ac b/synfig-studio/trunk/configure.ac index 2518b76..b11c841 100755 --- a/synfig-studio/trunk/configure.ac +++ b/synfig-studio/trunk/configure.ac @@ -144,12 +144,15 @@ AC_COMPILE_IFELSE([ AC_DEFINE([HASH_MAP_CLASS],[HASH_MAP_NAMESPACE::unordered_map],[The template name for unordered maps.]) AC_DEFINE([HASH_MAP_H],[],[The header file to include for unordered maps.]) AC_DEFINE([HASH_MAP_NAMESPACE],[std::tr1],[The namespace for unordered maps.]) + AC_DEFINE([FUNCTIONAL_H],[],[The header file for hash.]) + AC_DEFINE([FUNCTIONAL_HASH_ON_STRING],[1],[Define to 1 if hash needs to use T=String rather than T=char* to hash strings.]) ],[ AC_MSG_RESULT([no]) AC_CHECK_HEADERS([ext/hash_map],[ AC_DEFINE([HASH_MAP_CLASS],[HASH_MAP_NAMESPACE::hash_map],[The template name for unordered maps.]) AC_DEFINE([HASH_MAP_H],[],[The header file to include for unordered maps.]) AC_DEFINE([HASH_MAP_NAMESPACE],[__gnu_cxx],[The namespace for unordered maps.]) + AC_DEFINE([FUNCTIONAL_H],[],[The header file for hash.]) ],[ AC_MSG_ERROR([C++ compiler does not seem to support unordered containers]) ]) diff --git a/synfig-studio/trunk/src/gtkmm/duck.h b/synfig-studio/trunk/src/gtkmm/duck.h index 2a38d64..5ea5446 100644 --- a/synfig-studio/trunk/src/gtkmm/duck.h +++ b/synfig-studio/trunk/src/gtkmm/duck.h @@ -46,15 +46,25 @@ #ifdef HASH_MAP_H #include HASH_MAP_H +#include FUNCTIONAL_H + #ifndef __STRING_HASH__ #define __STRING_HASH__ class StringHash { +# ifdef FUNCTIONAL_HASH_ON_STRING + HASH_MAP_NAMESPACE::hash hasher_; +# else // FUNCTIONAL_HASH_ON_STRING HASH_MAP_NAMESPACE::hash hasher_; +# endif // FUNCTIONAL_HASH_ON_STRING public: size_t operator()(const synfig::String& x)const { +# ifdef FUNCTIONAL_HASH_ON_STRING + return hasher_(x); +# else // FUNCTIONAL_HASH_ON_STRING return hasher_(x.c_str()); +# endif // FUNCTIONAL_HASH_ON_STRING } }; #endif diff --git a/synfig-studio/trunk/src/gtkmm/duckmatic.h b/synfig-studio/trunk/src/gtkmm/duckmatic.h index b8d8247..fbbadae 100644 --- a/synfig-studio/trunk/src/gtkmm/duckmatic.h +++ b/synfig-studio/trunk/src/gtkmm/duckmatic.h @@ -52,15 +52,25 @@ #ifdef HASH_MAP_H #include HASH_MAP_H +#include FUNCTIONAL_H + #ifndef __STRING_HASH__ #define __STRING_HASH__ class StringHash { +# ifdef FUNCTIONAL_HASH_ON_STRING + HASH_MAP_NAMESPACE::hash hasher_; +# else // FUNCTIONAL_HASH_ON_STRING HASH_MAP_NAMESPACE::hash hasher_; +# endif // FUNCTIONAL_HASH_ON_STRING public: size_t operator()(const synfig::String& x)const { +# ifdef FUNCTIONAL_HASH_ON_STRING + return hasher_(x); +# else // FUNCTIONAL_HASH_ON_STRING return hasher_(x.c_str()); +# endif // FUNCTIONAL_HASH_ON_STRING } }; #endif