Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/ObjectOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ HTREEITEM ObjectOptions::_FindOrDont(const char* pLabel, HTREEITEM startPoint)
std::list<HTREEITEM> itemsToEx;
itemsToEx.push_back(startPoint);

while (itemsToEx.front()) {
while (!itemsToEx.empty() && itemsToEx.front()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is HTREEITEM a pointer?

Maybe just do while (!itemsToEx.empty())? Why test for front() here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, only testing for empty should resolve this here, as when not empty you should always have a front iterator.

Copy link
Author

@Caball009 Caball009 Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me if the code can handle a nullptr as element of itemsToEx, so this seemed to me the safest option.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is HTREEITEM a pointer?

Yes. typedef struct _TREEITEM *HTREEITEM;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any evidence that null is added into the container?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps prevent it from adding null to the list? What would be the point of a null entry in the list? Would it do anything?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps prevent it from adding null to the list?

That requires 2 checks, or 3 if we can't guarantee that the function parameter is never null.

What would be the point of a null entry in the list? Would it do anything?

I'm not sure and frankly I'm not sure it's worth my time to find out. I'd assume that replacing the MFC code is going to happen if we decide to revamp the World Builder.

char buffer[_MAX_PATH];
HTREEITEM hItem = itemsToEx.front();
itemsToEx.pop_front();
Expand Down
2 changes: 1 addition & 1 deletion GeneralsMD/Code/Tools/WorldBuilder/src/ObjectOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ HTREEITEM ObjectOptions::_FindOrDont(const char* pLabel, HTREEITEM startPoint)
std::list<HTREEITEM> itemsToEx;
itemsToEx.push_back(startPoint);

while (itemsToEx.front()) {
while (!itemsToEx.empty() && itemsToEx.front()) {
char buffer[_MAX_PATH];
HTREEITEM hItem = itemsToEx.front();
itemsToEx.pop_front();
Expand Down
Loading