Yes, you found it. That is the git commit in question. Reading through the thread, you pointed me at, I found the post by Manolo here
The source code of Fl_Multi_Label::label(Fl_Menu_Item* o) is
Fl::set_labeltype(_FL_MULTI_LABEL, multi_labeltype, multi_measure);
o->label(_FL_MULTI_LABEL, (const char*)this);
Thus, the difference between the 1st and the 2nd approaches listed above
is the call to Fl::set_labeltype(). Indeed using the 1st approach once
and then the 2nd approach produces correct multi-labelled menu items.
The API inconsistency could thus be solved adding an Fl_Multi_Label
constructor:
Fl_Multi_Label::Fl_Multi_Label() {
static unsigned count = 0;
if (!count++) Fl::set_labeltype(_FL_MULTI_LABEL, multi_labeltype, multi_measure);
}
The nagging question is why does calling item.image *just once* allow all the images to be displayed?
Digging into the docs. item.image is actually a fluid compatibility
code which just calls Fl_Pixmap's label method.
So therefore you can replace
item->image(L_redx_pixmap);
with
Fl_Pixmap* pm = &L_redx_pixmap;
pm->label(item);
and the other menu items now display images. Therefore, it must be
something in the label method.
Just as Manolo concluded, I looked at the implementation of label method for pixmap.
void Fl_Pixmap::label(Fl_Menu_Item* m) {
Fl::set_labeltype(_FL_IMAGE_LABEL, labeltype, Fl_Image::measure);
m->label(_FL_IMAGE_LABEL, (const char*)this);
}
I agree with Manolo that Fl::set_labeltype line is allowing all the menu item
images to be displayed. It only needs to be called once.
It is defined as
"Sets the functions to call to draw and measure a specific labeltype."
So I tried to call this line
Fl::set_labeltype(_FL_IMAGE_LABEL, Fl_Image::labeltype, Fl_Image::measure);
but unfortunately labeltype and measure functions are protected, not public.
I'm not sure how to solve this issue. An easy fix would be to revert the example code to the original. But would that just be hiding the real bug. I'm just not sure.