Commit 587472de authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'PolyLineProps' into 'master'

Poly line props

apply patch from Lukas Prediger to fix varios bugs with the polyline properties. #14 

See merge request !34
parents 243c5bf6 24315f46
Pipeline #102 skipped
......@@ -2132,12 +2132,12 @@ typename PolyLineT<PointT>::CustomPropertyHandle PolyLineT<PointT>::custom_prop_
template <class PointT>
typename PolyLineT<PointT>::CustomProperty* PolyLineT<PointT>::custom_prop(CustomPropertyHandle _handle) {
return (_handle >= 0 ? cprop_enum[_handle] : 0);
return (_handle >= 0 && _handle < get_num_custom_properties() ? cprop_enum[_handle] : NULL);
}
template <class PointT>
const typename PolyLineT<PointT>::CustomProperty* PolyLineT<PointT>::custom_prop(CustomPropertyHandle _handle) const {
return (_handle >= 0 ? cprop_enum[_handle] : 0);
return (_handle >= 0 && _handle < get_num_custom_properties() ? cprop_enum[_handle] : NULL);
}
template <class PointT>
......@@ -2145,10 +2145,10 @@ typename PolyLineT<PointT>::CustomPropertyHandle PolyLineT<PointT>::
request_custom_property(const std::string& _name,
unsigned int _prop_size) {
typename CustomPropertyMap::iterator entry = custom_properties.find(_name);
CustomProperty* pcontainer = 0;
CustomPropertyHandle h = get_custom_property_handle(_name);
CustomProperty* pcontainer = custom_prop(h);
if (entry == custom_properties.end()) {
if (!pcontainer) {
// create new property container
pcontainer = new CustomProperty;
......@@ -2166,8 +2166,6 @@ typename PolyLineT<PointT>::CustomPropertyHandle PolyLineT<PointT>::
cprop_enum.push_back(pcontainer);
} else {
pcontainer = entry->second;
if (++pcontainer->ref_count < 1)
pcontainer->ref_count = 1;
}
......@@ -2181,7 +2179,7 @@ void PolyLineT<PointT>::
CustomProperty* p = custom_prop(_prop_handle);
if (p && --p->ref_count <= 0)
if (p && --(p->ref_count) <= 0)
p->prop_data.clear();
}
......@@ -2189,14 +2187,8 @@ template <class PointT>
void PolyLineT<PointT>::
release_custom_property(const std::string& _name) {
typename CustomPropertyMap::iterator entry = custom_properties.find(_name);
if (entry != custom_properties.end()) {
CustomProperty* p = entry->second;
release_custom_property(custom_prop_handle(p));
}
CustomPropertyHandle h = get_custom_property_handle(_name);
release_custom_property(h);
}
template <class PointT>
......@@ -2206,7 +2198,7 @@ typename PolyLineT<PointT>::CustomPropertyHandle PolyLineT<PointT>::
typename CustomPropertyMap::const_iterator it = custom_properties.find(_name);
if (it == custom_properties.end())
return 0;
return -1;
return custom_prop_handle(it->second);
}
......@@ -2215,7 +2207,7 @@ template <class PointT>
const std::string PolyLineT<PointT>::
get_custom_property_name(CustomPropertyHandle _property_handle) const {
CustomProperty* p = custom_prop(_property_handle);
const CustomProperty* p = custom_prop(_property_handle);
if (p)
return p->name;
......@@ -2277,9 +2269,9 @@ void PolyLineT<PointT>::
return;
}
if (_property_handle) {
const CustomProperty* p = custom_prop(_property_handle);
const CustomProperty* p = custom_prop(_property_handle);
if (p) {
unsigned int offset = p->prop_size * _i;
......@@ -2381,7 +2373,7 @@ const void* PolyLineT<PointT>::
else
std::cerr << "PolyLineT::get_custom_property_buffer - invalid handle" << std::endl;
return 0;
return NULL;
}
template <class PointT>
......@@ -2397,7 +2389,7 @@ typename PolyLineT<PointT>::CustomPropertyHandle PolyLineT<PointT>::
if (_i < get_num_custom_properties())
return CustomPropertyHandle(_i);
else
return 0;
return -1;
}
//=============================================================================
......
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