Commit 0fa8c523 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

* Fixed wrong property widget registration for vector type properties.

* Fixed RTTI type inference in PropertyWidgetFactory::createWidget()
parent 0b1ebc43
......@@ -154,11 +154,6 @@ namespace campvis {
DoubleAdjusterWidget* _adjusters[size];
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template class PropertyWidgetRegistrar<VecPropertyWidget<2>, typename VecPropertyWidgetTraits<2>::PropertyType>;
template class PropertyWidgetRegistrar<VecPropertyWidget<3>, typename VecPropertyWidgetTraits<3>::PropertyType>;
template class PropertyWidgetRegistrar<VecPropertyWidget<4>, typename VecPropertyWidgetTraits<4>::PropertyType>;
// ================================================================================================
template<size_t SIZE>
......@@ -292,6 +287,13 @@ namespace campvis {
void onValueChanged(double value) { onValueChangedImpl(); };
};
// ================================================================================================
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template class PropertyWidgetRegistrar<Vec2PropertyWidget, typename VecPropertyWidgetTraits<2>::PropertyType, 5>;
template class PropertyWidgetRegistrar<Vec3PropertyWidget, typename VecPropertyWidgetTraits<3>::PropertyType, 5>;
template class PropertyWidgetRegistrar<Vec4PropertyWidget, typename VecPropertyWidgetTraits<4>::PropertyType, 5>;
}
#endif // FLOATPROPERTYWIDGET_H__
......@@ -154,11 +154,6 @@ namespace campvis {
IntAdjusterWidget* _adjusters[size];
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template class PropertyWidgetRegistrar<IVecPropertyWidget<2>, typename IVecPropertyWidgetTraits<2>::PropertyType>;
template class PropertyWidgetRegistrar<IVecPropertyWidget<3>, typename IVecPropertyWidgetTraits<3>::PropertyType>;
template class PropertyWidgetRegistrar<IVecPropertyWidget<4>, typename IVecPropertyWidgetTraits<4>::PropertyType>;
// ================================================================================================
template<size_t SIZE>
......@@ -277,5 +272,12 @@ namespace campvis {
void onValueChanged(int value) { onValueChangedImpl(); };
};
// ================================================================================================
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template class PropertyWidgetRegistrar<IVec2PropertyWidget, typename IVecPropertyWidgetTraits<2>::PropertyType, 5>;
template class PropertyWidgetRegistrar<IVec3PropertyWidget, typename IVecPropertyWidgetTraits<3>::PropertyType, 5>;
template class PropertyWidgetRegistrar<IVec4PropertyWidget, typename IVecPropertyWidgetTraits<4>::PropertyType, 5>;
}
#endif // INTPROPERTYWIDGET_H__
......@@ -26,6 +26,8 @@
#include <functional>
#include "core/properties/abstractproperty.h"
namespace campvis {
tbb::atomic<PropertyWidgetFactory*> PropertyWidgetFactory::_singleton;
......@@ -54,7 +56,7 @@ namespace campvis {
if (ptr != nullptr) {
PropertyWidgetMapType::iterator it = _propertyWidgetMap.lower_bound(typeIndex);
if (it == _propertyWidgetMap.end() || it->first != typeIndex) {
//_propertyWidgetMap.insert(it, std::make_pair(typeIndex, ptr));
_propertyWidgetMap.insert(it, std::make_pair(typeIndex, ptr));
}
else {
tgtAssert(false, "Double-registered a property widget for the same type.");
......@@ -67,16 +69,17 @@ namespace campvis {
return _propertyWidgetMap.size() + _fallbackCreatorMap.size();
}
AbstractPropertyWidget* PropertyWidgetFactory::createWidget(AbstractProperty* property, DataContainer* dc /*= 0*/, QWidget* parent /*= 0*/) {
AbstractPropertyWidget* PropertyWidgetFactory::createWidget(AbstractProperty* prop, DataContainer* dc /*= 0*/, QWidget* parent /*= 0*/) {
// look if we find a direct a direct match
PropertyWidgetMapType::iterator it = _propertyWidgetMap.find(std::type_index(typeid(property)));
if (it != _propertyWidgetMap.end())
return it->second(property, dc, parent);
PropertyWidgetMapType::iterator it = _propertyWidgetMap.find(std::type_index(typeid(*prop)));
if (it != _propertyWidgetMap.end()) {
return it->second(prop, dc, parent);
}
// otherwise we have to do this kind of slow search
for (std::multimap<int, FallbackPropertyWidgetCreateFunctionPointer>::iterator it = _fallbackCreatorMap.begin(); it != _fallbackCreatorMap.end(); ++it) {
// let each registered widget try to create a widget for the property
AbstractPropertyWidget* toReturn = it->second(property, dc, parent);
AbstractPropertyWidget* toReturn = it->second(prop, dc, parent);
if (toReturn != nullptr)
return toReturn;
}
......
......@@ -157,7 +157,7 @@ namespace campvis {
template<typename WidgetType, typename PropertyType, int PRIORITY>
const size_t PropertyWidgetRegistrar<WidgetType, PropertyType, PRIORITY>::_factoryId
= PropertyWidgetFactory::getRef().registerPropertyWidget(
typeid(PropertyType*),
typeid(PropertyType),
&PropertyWidgetRegistrar<WidgetType, PropertyType, PRIORITY>::create,
&PropertyWidgetRegistrar<WidgetType, PropertyType, PRIORITY>::tryCreate,
PRIORITY
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment