Le 26/06/2016 16:27, Richard Heck a écrit :

The attached patch almost works. (Details like the icon are not yet
there.) There are some big problems, however, which seem to derive from
the fact that the whole menu and toolbar setup is not really designed to
be modified on the fly.

The problem here seems to trace to how FuncRequest objects are handled
by our Action class. Namely, when an Action is created, it retains a
const & to a FuncRequest. So one can't pass a temporary. This means that
I have to create a kind of cache for these objects. The idea was to keep
them around as long as we need them. But it turns out that we need them
rather a long time. If you look at the FIXME in the patch, you will see
what I mean. Clearing the menu is supposed to delete any actions it owns:

void QMenu::clear ()
Removes all the menu's actions. Actions owned by the menu and not shown
in any other widget are deleted.

In fact, however, they seem still to be around, and if we clear the
cache we eventually segfault. If we don't clear the cache, we are
effectively leaking memory.

I can make this work by changing the Action class so it makes a copy of
the FuncRequest. But I worry that this is just hiding the real problem,
and that all these Action objects we're creating are leaking, or at
least being retained for no good reason.

Help wanted!


Thanks. I am a bit busy right now, but I starred your message to come
back to it later (unless you get help from somebody else in the meanwhile).

Guillaume


Reply via email to