Mercurial > octave-antonio
diff libinterp/dldfcn/__init_fltk__.cc @ 17898:8c33abdd2f9a
maint: Avoid using NULL in C++ code.
* qtinfo/parser.cc, profiler.cc, profiler.h, txt-eng-ft.cc,
__init_fltk__.cc, ov-fcn-handle.cc, ov-java.cc, mkoctfile.in.cc:
Avoid using NULL in C++ code.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 11 Nov 2013 01:49:57 -0500 |
parents | 7aadb87f599a |
children | 8e9532632838 |
line wrap: on
line diff
--- a/libinterp/dldfcn/__init_fltk__.cc Sun Nov 10 21:10:41 2013 +0100 +++ b/libinterp/dldfcn/__init_fltk__.cc Mon Nov 11 01:49:57 2013 -0500 @@ -290,7 +290,7 @@ { const Fl_Menu_Item *m = static_cast<const Fl_Menu_Item*> (& (menubar->menu ()[t])); - if ((m->label () != NULL) && m->visible ()) + if (m->label () && m->visible ()) n++; } @@ -337,7 +337,7 @@ else { // End of submenu? Pop back one level. - if (m->label () == NULL) + if (m->label ()) { std::size_t idx = menupath.find_last_of ("/"); if (idx != std::string::npos) @@ -421,7 +421,7 @@ { Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( fltk_label.c_str ())); - if (item != NULL) + if (item) { std::string acc = uimenup.get_accelerator (); if (acc.length () > 0) @@ -440,13 +440,13 @@ { Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( fltk_label.c_str ())); - if (item != NULL) + if (item) { if (!uimenup.get_callback ().is_empty ()) item->callback (static_cast<Fl_Callback*> (script_cb), static_cast<void*> (&uimenup)); else - item->callback (NULL, static_cast<void*> (0)); + item->callback (0, static_cast<void*> (0)); } } } @@ -458,7 +458,7 @@ { Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( fltk_label.c_str ())); - if (item != NULL) + if (item) { if (uimenup.is_enable ()) item->activate (); @@ -475,7 +475,7 @@ { Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( fltk_label.c_str ())); - if (item != NULL) + if (item) { Matrix rgb = uimenup.get_foregroundcolor_rgb (); @@ -504,7 +504,7 @@ Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (&menubar->menu () [idx]); itemflags = item->flags; - if (item->label () != NULL) + if (item->label ()) break; } @@ -528,7 +528,7 @@ { Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item (fltk_label.c_str ())); - if (item != NULL) + if (item) { if (uimenup.is_visible ()) item->show (); @@ -551,19 +551,7 @@ const Fl_Menu_Item* item = menubar->find_item (fltk_label.c_str ()); - if (item == NULL) - { - Matrix uimenu_ch = find_uimenu_children (uimenup); - int len = uimenu_ch.numel (); - int flags = 0; - if (len > 0) - flags = FL_SUBMENU; - if (len == 0 && uimenup.is_checked ()) - flags += FL_MENU_TOGGLE + FL_MENU_VALUE; - menubar->add (fltk_label.c_str (), 0, 0, 0, flags); - item_added = true; - } - else + if (item) { //avoid duplicate menulabels std::size_t idx1 = fltk_label.find_last_of ("("); @@ -582,6 +570,18 @@ valstream << val; fltk_label += "(" + valstream.str () + ")"; } + else + { + Matrix uimenu_ch = find_uimenu_children (uimenup); + int len = uimenu_ch.numel (); + int flags = 0; + if (len > 0) + flags = FL_SUBMENU; + if (len == 0 && uimenup.is_checked ()) + flags += FL_MENU_TOGGLE + FL_MENU_VALUE; + menubar->add (fltk_label.c_str (), 0, 0, 0, flags); + item_added = true; + } } while (!item_added); uimenup.set_fltk_label (fltk_label);