Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: Submenus in plugins



On Tue, 4 Feb 2003, Klaus Schmidinger wrote:

>Jan Ekholm wrote:
>> 
>> On Tue, 4 Feb 2003, Klaus Schmidinger wrote:
>> 
>> >Jan Ekholm wrote:
>> >>
>> >> On Tue, 4 Feb 2003, Klaus Schmidinger wrote:
>> >>
>> >> >Why don't you just take a look at the existing VDR code to see how it is
>> >> >done there? ;-)
>> >> >
>> >> >You should do something like this:
>> >> >
>> >> >  return AddSubMenu(new cMyMenu(MyParameters...));
>> >>
>> >> Heh, I feel like a moron. I did try to find something, but I just searched
>> >> for the wrong things. Would this also work for moving up the hierarchy,
>> >> ie. activating a parent menu, or does VDR take care of that automagically
>> >> once I use AddSubMenu() and I'd better leave it alone?
>> >
>> >Simply return osBack to go up one level.
>> 
>> Hmm, does VDR assume ownership of menus it gets passed, ie. does it nuke
>> them when it doesn't need them anymore?
>
>Yes, once a menu's ProcessKey() returns osBack the menu gets deleted.
>
>> That it should not do, but it's
>> not too easy to find out what really happens. Should every menu added with
>> AddSubMenu() be allocated on the fly?
>
>Yes, that's how it's supposed to work. Look at the existing code to see how
>this is done.

I never noticed the "delete" in CloseSubMenu(), and started to get really
weird behaviour with my menus as they are all built up in advance. Having
them deleted obviously caused some problems, but it should be fairly
trivial for me to fix that code.

>> Same goes with strings, VDR seems to assume ownership of a lot of strings,
>> resulting in quite a few unnecessary core dumps.
>
>What strings exactly are you referring to?

At least menu items and titles. But that point is moot as the whole
submenu is "owned" by VDR, and thus is the proper way to go. I usually use
std::string internally, and that meant that just passing mystring.c_str()
to VDR didn't really work too well. I assumed that VDR methods taking 
"const char *" as parameters would not delete the given data.

Would it be possible to put in a lite blurb about what objects VDR assumes
ownership about into PLUGINS.html?

Thanks a lot for your help, Klaus.

-- 

              Many an ancient lord's last words had been:
         "You can't kill me because I've got magic aaargh...."
                                      -- Terry Pratchett, Interesting Times



-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index