Commits

nat_linden committed ef55c1a

Backed out changeset a25bfa87418d (using std::type_info::name())
The changeset above touched every consumer of the two LLRegistrySingletons
originally defined with std::type_info* as keys. Those two
LLRegistrySingletons were changed to use const char* as keys, then all
consumers were changed to pass std::type_info::name() instead of the plain
std::type_info* pointer -- to deal with the observed fact that on Linux, a
given type might produce different std::type_info* pointers in different load
modules. Since then, Richard turned up the fascinating fact that at least some
implementations of gcc's std::type_info::before() method already accommodate
this peculiarity. It seems worth backing out the (dismayingly pervasive)
change to see if properly using std::type_info::before() as the map comparator
will work just as well, with conceptually simpler source code.
This backout is transitional: we don't expect things to build/run properly
until we've cherry-picked certain other pertinent changes.

Comments (0)

Files changed (14)

indra/llcommon/llregistry.h

 #include <list>
 
 #include <boost/type_traits.hpp>
-#include <boost/static_assert.hpp>
 #include "llsingleton.h"
+#include "lltypeinfolookup.h"
 
 template <typename T>
 class LLRegistryDefaultComparator
 	bool operator()(const T& lhs, const T& rhs) { return lhs < rhs; }
 };
 
+template <typename KEY, typename VALUE>
+struct LLRegistryMapSelector
+{
+    typedef std::map<KEY, VALUE> type;
+};
+
+template <typename VALUE>
+struct LLRegistryMapSelector<std::type_info*, VALUE>
+{
+    typedef LLTypeInfoLookup<VALUE> type;
+};
+
+template <typename VALUE>
+struct LLRegistryMapSelector<const std::type_info*, VALUE>
+{
+    typedef LLTypeInfoLookup<VALUE> type;
+};
+
 template <typename KEY, typename VALUE, typename COMPARATOR = LLRegistryDefaultComparator<KEY> >
 class LLRegistry
 {
-	// Do not use LLRegistry with KEY = std::type_info* or KEY = const std::type_info*.
-	// This is known to fail on Linux.
-	// If you must use LLRegistry with dynamic type info, use KEY = const char*
-	// and pass std::type_info::name(); this works across load modules.
-	// Disallow both std::type_info* and const std::type_info*. First remove
-	// the pointer, then remove const, then compare is_same<std::type_info>.
-	BOOST_STATIC_ASSERT(! (boost::is_same<typename boost::remove_const<typename boost::remove_pointer<KEY>::type>::type, std::type_info>::value));
-
 public:
 	typedef LLRegistry<KEY, VALUE, COMPARATOR>											registry_t;
 	typedef typename boost::add_reference<typename boost::add_const<KEY>::type>::type	ref_const_key_t;
 	{
 		friend class LLRegistry<KEY, VALUE, COMPARATOR>;
 	public:
-		typedef std::map<KEY, VALUE> registry_map_t;
+		typedef typename LLRegistryMapSelector<KEY, VALUE>::type registry_map_t;
 
 		bool add(ref_const_key_t key, ref_const_value_t value)
 		{

indra/llui/llfloater.cpp

 }
 
 // defaults for floater param block pulled from widgets/floater.xml
-static LLWidgetNameRegistry::StaticRegistrar sRegisterFloaterParams(typeid(LLFloater::Params).name(), "floater");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterFloaterParams(&typeid(LLFloater::Params), "floater");
 
 LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
 :	LLPanel(),	// intentionally do not pass params here, see initFromParams

indra/llui/llradiogroup.cpp

 
 	LLSD mPayload;	// stores data that this item represents in the radio group
 };
-static LLWidgetNameRegistry::StaticRegistrar register_radio_item(typeid(LLRadioGroup::ItemParams).name(), "radio_item");
+static LLWidgetNameRegistry::StaticRegistrar register_radio_item(&typeid(LLRadioGroup::ItemParams), "radio_item");
 
 LLRadioGroup::Params::Params()
 :	allow_deselect("allow_deselect"),

indra/llui/llrngwriter.cpp

 
 	// add includes for all possible children
 	const std::type_info* type = *LLWidgetTypeRegistry::instance().getValue(type_name);
-	const widget_registry_t* widget_registryp = LLChildRegistryRegistry::instance().getValue(type->name());
+	const widget_registry_t* widget_registryp = LLChildRegistryRegistry::instance().getValue(type);
 	
 	// add include declarations for all valid children
 	for (widget_registry_t::Registrar::registry_map_t::const_iterator it = widget_registryp->currentRegistrar().beginItems();

indra/llui/llscrolllistcolumn.cpp

 const S32 MIN_COLUMN_WIDTH = 20;
 
 // defaults for LLScrollColumnHeader param block pulled from widgets/scroll_column_header.xml
-static LLWidgetNameRegistry::StaticRegistrar sRegisterColumnHeaderParams(typeid(LLScrollColumnHeader::Params).name(), "scroll_column_header");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterColumnHeaderParams(&typeid(LLScrollColumnHeader::Params), "scroll_column_header");
 
 //---------------------------------------------------------------------------
 // LLScrollColumnHeader

indra/llui/lltextbase.cpp

 //
 
 // register LLTextBase::Params under name "textbase"
-static LLWidgetNameRegistry::StaticRegistrar sRegisterTextBaseParams(typeid(LLTextBase::Params).name(), "textbase");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterTextBaseParams(&typeid(LLTextBase::Params), "textbase");
 
 LLTextBase::LineSpacingParams::LineSpacingParams()
 :	multiple("multiple", 1.f),

indra/llui/lltooltip.cpp

 }
 
 // defaults for floater param block pulled from widgets/floater.xml
-static LLWidgetNameRegistry::StaticRegistrar sRegisterInspectorParams(typeid(LLInspector::Params).name(), "inspector");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterInspectorParams(&typeid(LLInspector::Params), "inspector");
 
 //
 // LLToolTip

indra/llui/lluictrlfactory.cpp

 void LLUICtrlFactory::registerWidget(const std::type_info* widget_type, const std::type_info* param_block_type, const std::string& tag)
 {
 	// associate parameter block type with template .xml file
-	std::string* existing_tag = LLWidgetNameRegistry::instance().getValue(param_block_type->name());
+	std::string* existing_tag = LLWidgetNameRegistry::instance().getValue(param_block_type);
 	if (existing_tag != NULL)
 	{
 		if(*existing_tag != tag)
 			return;
 		}
 	}
-	LLWidgetNameRegistry::instance().defaultRegistrar().add(param_block_type->name(), tag);
+	LLWidgetNameRegistry::instance().defaultRegistrar().add(param_block_type, tag);
 	//FIXME: comment this in when working on schema generation
 	//LLWidgetTypeRegistry::instance().defaultRegistrar().add(tag, widget_type);
 	//LLDefaultParamBlockRegistry::instance().defaultRegistrar().add(widget_type, &get_empty_param_block<T>);
 //static 
 const std::string* LLUICtrlFactory::getWidgetTag(const std::type_info* widget_type)
 {
-	return LLWidgetNameRegistry::instance().getValue(widget_type->name());
+	return LLWidgetNameRegistry::instance().getValue(widget_type);
 }
 

indra/llui/lluictrlfactory.h

 	friend class LLSingleton<LLDefaultChildRegistry>;
 };
 
-// lookup widget name by type (actually by std::type_info::name())
+// lookup widget name by type
 class LLWidgetNameRegistry 
-:	public LLRegistrySingleton<const char*, std::string, LLWidgetNameRegistry , LLCompareTypeID>
+:	public LLRegistrySingleton<const std::type_info*, std::string, LLWidgetNameRegistry , LLCompareTypeID>
 {};
 
 // lookup function for generating empty param block by widget type

indra/llui/llxuiparser.cpp

 
 	// add includes for all possible children
 	const std::type_info* type = *LLWidgetTypeRegistry::instance().getValue(type_name);
-	const widget_registry_t* widget_registryp = LLChildRegistryRegistry::instance().getValue(type->name());
+	const widget_registry_t* widget_registryp = LLChildRegistryRegistry::instance().getValue(type);
 
 	// add choices for valid children
 	if (widget_registryp)

indra/llui/llxuiparser.h

 
 typedef LLRegistry<std::string, LLWidgetCreatorFunc> widget_registry_t;
 
-// const char* key used for std::type_info::name() string
 class LLChildRegistryRegistry
-: public LLRegistrySingleton<const char*, widget_registry_t, LLChildRegistryRegistry>
+: public LLRegistrySingleton<const std::type_info*, widget_registry_t, LLChildRegistryRegistry>
 {};
 
 

indra/newview/llavatarlistitem.cpp

 S32 LLAvatarListItem::sNameRightPadding = 0;
 S32 LLAvatarListItem::sChildrenWidths[LLAvatarListItem::ALIC_COUNT];
 
-static LLWidgetNameRegistry::StaticRegistrar sRegisterAvatarListItemParams(typeid(LLAvatarListItem::Params).name(), "avatar_list_item");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterAvatarListItemParams(&typeid(LLAvatarListItem::Params), "avatar_list_item");
 
 LLAvatarListItem::Params::Params()
 :	default_style("default_style"),

indra/newview/llinventorylistitem.cpp

 #include "llinventorymodel.h"
 #include "llviewerinventory.h"
 
-static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelInventoryListItemBaseParams(typeid(LLPanelInventoryListItemBase::Params).name(), "inventory_list_item");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelInventoryListItemBaseParams(&typeid(LLPanelInventoryListItemBase::Params), "inventory_list_item");
 
 static const S32 WIDGET_SPACING = 3;
 

indra/newview/llwearableitemslist.cpp

 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
-static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelClothingListItem(typeid(LLPanelClothingListItem::Params).name(), "clothing_list_item");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelClothingListItem(&typeid(LLPanelClothingListItem::Params), "clothing_list_item");
 
 
 LLPanelClothingListItem::Params::Params()
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 
-static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelBodyPartsListItem(typeid(LLPanelBodyPartsListItem::Params).name(), "bodyparts_list_item");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelBodyPartsListItem(&typeid(LLPanelBodyPartsListItem::Params), "bodyparts_list_item");
 
 
 LLPanelBodyPartsListItem::Params::Params()
 	return TRUE;
 }
 
-static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelDeletableWearableListItem(typeid(LLPanelDeletableWearableListItem::Params).name(), "deletable_wearable_list_item");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelDeletableWearableListItem(&typeid(LLPanelDeletableWearableListItem::Params), "deletable_wearable_list_item");
 
 LLPanelDeletableWearableListItem::Params::Params()
 :	delete_btn("delete_btn")
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
-static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelDummyClothingListItem(typeid(LLPanelDummyClothingListItem::Params).name(), "dummy_clothing_list_item");
+static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelDummyClothingListItem(&typeid(LLPanelDummyClothingListItem::Params), "dummy_clothing_list_item");
 
 LLPanelDummyClothingListItem::Params::Params()
 :	add_panel("add_panel"),