Hi!
I have a simple menu derived from cOsdMenu which displays selectable cOsdItem's.
Now I want to update the text of the cOsdItem's from a separate thread, which I do basically this way:
cOsdItem* item = Get(index); if (item) { item->SetText(text); Display(); }
But this doesn't seem to work very well. Sometimes only some of the cOsdItems are correctly shown with the new text, sometimes parts of the menu are completly invisible until I move the selection cursor over this area.
Any suggestions? Maybe this isn't possible at all?
Regards,
Tobias
Tobias Grimm wrote:
Now I want to update the text of the cOsdItem's from a separate thread, which I do basically this way:
[..]
But this doesn't seem to work very well. Sometimes only some of the cOsdItems are correctly shown with the new text, sometimes parts of the menu are completly invisible until I move the selection cursor over this area.
I don't think that updating menus from other threads is allowed by design. My suggestion is to take a look on how the dynamic updating recordings menu works in vdr-1.3.33 and newer. Basically, a background thread collects the data, and the foreground thread updates the menu on the next ProcessKey(kNone) call.
Cheers,
Udo
Udo Richter wrote:
I don't think that updating menus from other threads is allowed by design.
Surly not, I just thought, there might be an easy way to make this thread safe.
My suggestion is to take a look on how the dynamic updating recordings menu works in vdr-1.3.33 and newer. Basically, a background thread collects the data, and the foreground thread updates the menu on the next ProcessKey(kNone) call.
Ok, I see - I already thought about this. It just didn't felt right, because I see ProcessKey() as some kind of message loop, which I don't want to give too much responsibilities. In my current design, the menu has a presenter (MVP), which is an observer that get's notified by the thread. I will probably let the presenter collect the items to be updated and when the menu comes across a kNone in ProcessKey, it lets the presenter update any items it may have in it's "update queue". Surely not the best solution, but maybe I will find a better one later on.
Thanks,
Tobias