DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2680
Version: 1.3-current
FWIW, here is my *complete* patch, including the test case and lots of
printf() statements I used to find this particular problem with the user's
code (see attached file Fl_Menu_test.patch. Look for the output text "\n***
GOT YOU! ***\n\n" to see where (and when) the hangup would happen
otherwise.
Link: http://www.fltk.org/str.php?L2680
Version: 1.3-current
Index: src/Fl_Menu.cxx
===================================================================
--- src/Fl_Menu.cxx (revision 8863)
+++ src/Fl_Menu.cxx (working copy)
@@ -56,10 +56,12 @@
// Advance a pointer to next visible or invisible item of a menu array,
// skipping the contents of submenus.
static const Fl_Menu_Item* next_visible_or_not(const Fl_Menu_Item* m) {
+ printf("%s:%d m=%p,
text=%s\n",__FUNCTION__,__LINE__,m,m->text?m->text:"<>"); fflush(stdout);
int nest = 0;
do {
if (!m->text) {
- if (!nest) return m;
+ if (!nest) { printf("%s:%d m=%p,
text=%s\n",__FUNCTION__,__LINE__,m,m->text?m->text:"<>"); fflush(stdout);
+ return m; }
nest--;
} else if (m->flags&FL_SUBMENU) {
nest++;
@@ -67,6 +69,7 @@
m++;
}
while (nest);
+ printf("%s:%d m=%p,
text=%s\n",__FUNCTION__,__LINE__,m,m->text?m->text:"<>"); fflush(stdout);
return m;
}
@@ -76,13 +79,23 @@
that you can advance through const and non-const data.
*/
const Fl_Menu_Item* Fl_Menu_Item::next(int n) const {
+ printf("%s:%d, n=%d\n",__FUNCTION__,__LINE__,n); fflush(stdout);
if (n < 0) return 0; // this is so selected==-1 returns NULL
const Fl_Menu_Item* m = this;
if (!m->visible()) n++;
+ printf("%s:%d, n=%d\n",__FUNCTION__,__LINE__,n); fflush(stdout);
while (n) {
+ printf("%s:%d, while(n) n=%d\n",__FUNCTION__,__LINE__,n); fflush(stdout);
m = next_visible_or_not(m);
- if (m->visible()) n--;
+ printf("%s:%d, while(n) n=%d, visible=%d,
text=%p\n",__FUNCTION__,__LINE__,n,m->visible(),m->text); fflush(stdout);
+ // if (m->visible() || !m->text) n--; // added: "|| !m->text"
+ if (m->visible() || !m->text ) { // added: "|| !m->text"
+ n--;
+ if (!m->visible()) { printf("\n*** GOT YOU! ***\n\n"); fflush(stdout); }
+ }
+ printf("%s:%d, while(n) n=%d\n",__FUNCTION__,__LINE__,n); fflush(stdout);
}
+ printf("%s:%d\n",__FUNCTION__,__LINE__); fflush(stdout);
return m;
}
Index: test/menubar.cxx
===================================================================
--- test/menubar.cxx (revision 8863)
+++ test/menubar.cxx (working copy)
@@ -176,6 +176,7 @@
{"&Charm", FL_ALT+'c'},
{"Truth", FL_ALT+'t'},
{"Beauty", FL_ALT+'b'},
+ {0,0, 0, 0, FL_MENU_INVISIBLE},
{0}
};
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs