PopupMenu::addCustomItem documentation quirk

In PopupMenu::addCustomItem documentation:

Appends a custom menu item that can't be used to trigger a result.

This will add a user-defined component to use as a menu item. It's the caller's responsibility to delete the component that is passed-in when it's no longer needed after the menu has been hidden.

If triggerMenuItemAutomaticallyWhenClicked is true, the menu itself will handle detection of a mouse-click on your component, and use that to trigger the menu ID specified in itemResultID. If this is false, the menu item can't be triggered, so itemResultID is not used.

This is no more the case as the PopupMenu::CustomComponent is a SingleThreadedReferenceCountedObject ?

I got this cause i was trying to delete the object myself... and finally banged on this.

You may have overlooked that there are two versions of PopupMenu::addCustomItem. One takes a CustomComponent* , and yes that's a SingleThreadedReferenceCountedObject, so the documentation for this one says:

The component passed in will be deleted by this menu when it's no longer needed.

And then there is a second version which takes a simple Component* . The latter needs to be deleted by the caller because a plain Component* not reference-counted, so the comment you quoted (which relates to this version) is correct.

ah sure drop that ! thanks

any chance to make both functions near each other in the documentation ?

Unfortunately no, although I admit it's confusing.

The version taking a CustomComponent needs to be below the class definition of CustomComponent, otherwise the code won't compile.

Oh hang on, that's not true. It's taking a pointer, so it's enough to have a forward declaration to CustomComponent at the top and then the definition below.

Cleaned that up - now the two PopupMenu::addCustomItem versions are next to each other.