View Issue Details

IDProjectCategoryView StatusLast Update
0001997NoesisGUIC++ SDKpublic2021-05-03 19:18
ReporterstevehAssigned Tosfernandez 
Status resolvedResolutionfixed 
Product Version3.0.9 
Target Version3.0.12Fixed in Version3.0.12 
Summary0001997: Const safety incorrect for ItemColelction::IndexOf
DescriptionHi guys, the parameter for ItemCollection::IndexOf are not const:

int ItemCollection::IndexOf(BaseComponent* item) const

(and likewise BaseCollection::IndexOfComponent etc). This prevents me from doing the following:

/*static*/ void MyCustomComponent::OnPropertyChanged(DependencyObject *pObject, const DependencyPropertyChangedEventArgs &rArgs)
    SelfClass *pSelf = DynamicCast<SelfClass*>(pObject);
    if (nullptr != pSelf)
        ItemCollection *pItems = GetItemCollection();
        if (nullptr != pItems)
            s32 nOldIdx = -1;
            s32 nNewIdx = -1;
            if (rArgs.oldValue != nullptr)
                nOldIdx = pItems->IndexOf(reinterpret_cast<const BaseComponent*>(rArgs.oldValue)); // Errors <-- cannot remove const

I can use a const_cast for now, but I don't see any reason why the parameter can't be const as it should only be checking to see if the address of the property is in the collection, it shouldn't need to mutate the object.
TagsNo tags attached.


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2021-05-02 15:35 steveh New Issue
2021-05-03 10:22 sfernandez Assigned To => sfernandez
2021-05-03 10:22 sfernandez Status new => assigned
2021-05-03 10:22 sfernandez Target Version => 3.0.12
2021-05-03 19:18 sfernandez Status assigned => resolved
2021-05-03 19:18 sfernandez Resolution open => fixed
2021-05-03 19:18 sfernandez Fixed in Version => 3.0.12