Skip to content

Commit

Permalink
#5127: Prevent exceptions when trying to access empty columns values …
Browse files Browse the repository at this point in the history
…on data view items.

This can happen if the tree model filter function is accessing columns on items that are created by the ResourceTreeView base class, which is unaware of those columns.
  • Loading branch information
codereader committed Jan 3, 2021
1 parent 7a533eb commit 28b719d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libs/wxutil/dataview/TreeModel.h
Expand Up @@ -213,22 +213,25 @@ class TreeModel :
// Don't implement operator bool() directly, it can be converted to integer
bool getBool() const
{
return getVariant().GetBool();
bool value;
return getVariant().Convert(&value) ? value : false;
}

int getInteger() const
{
return static_cast<int>(getVariant().GetInteger());
long value;
return getVariant().Convert(&value) ? static_cast<int>(value) : 0;
}

double getDouble() const
{
return getVariant().GetDouble();
double value;
return getVariant().Convert(&value) ? value : 0.0;
}

void* getPointer() const
{
return getVariant().GetVoidPtr();
return getVariant().IsNull() ? nullptr : getVariant().GetVoidPtr();
}

operator std::string() const
Expand Down

0 comments on commit 28b719d

Please sign in to comment.