Mercurial > hg > octave-shane
changeset 12286:45c97076c161 release-3-4-x
__fltk_uigetfile__.cc: style fixes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 29 Jan 2011 13:05:18 -0500 |
parents | db14b8095edd |
children | 0566e6fef0c0 |
files | src/ChangeLog src/DLD-FUNCTIONS/__fltk_uigetfile__.cc |
diffstat | 2 files changed, 32 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2011-01-29 John W. Eaton <jwe@octave.org> + + * DLD-FUNCTIONS/__fltk_uigetfile__.cc (__fltk_uigetfile__): + Don't allocate Fl_File_Chooser object with new. Delete unused + variable fargs. Allocate default retval values in initial + declaration. + 2011-01-29 John W. Eaton <jwe@octave.org> * DLD-FUNCTIONS/__init_fltk__.cc: Undefine Complex after
--- a/src/DLD-FUNCTIONS/__fltk_uigetfile__.cc +++ b/src/DLD-FUNCTIONS/__fltk_uigetfile__.cc @@ -38,22 +38,21 @@ #include "defun-dld.h" #include "file-ops.h" - DEFUN_DLD (__fltk_uigetfile__, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} __fltk_uigetfile__ (@dots{})\n\ Undocumented internal function.\n\ @end deftypefn") { - - // Expected argument list - // args(0) ... FileFilter in fltk format - // args(1) ... Title - // args(2) ... Default Filename - // args(3) ... PostionValue [x,y] - // args(4) ... SelectValue "on"/"off"/"dir"/"create" + // Expected argument list: + // + // args(0) ... FileFilter in fltk format + // args(1) ... Title + // args(2) ... Default Filename + // args(3) ... PostionValue [x,y] + // args(4) ... SelectValue "on"/"off"/"dir"/"create" - octave_value_list fargs, retval; + octave_value_list retval (3, octave_value (0)); std::string file_filter = args(0).string_value(); std::string title = args(1).string_value(); @@ -62,7 +61,7 @@ int multi_type = Fl_File_Chooser::SINGLE; std::string flabel = "Filename:"; - + std::string multi = args(4).string_value(); if (multi == "on") multi_type = Fl_File_Chooser::MULTI; @@ -75,31 +74,30 @@ multi_type = Fl_File_Chooser::CREATE; Fl_File_Chooser::filename_label = flabel.c_str (); - Fl_File_Chooser *fc = new Fl_File_Chooser (default_name.c_str (), file_filter.c_str (), multi_type, title.c_str ()); - fc->preview (0); + + Fl_File_Chooser fc (default_name.c_str (), file_filter.c_str (), + multi_type, title.c_str ()); + + fc.preview (0); if (multi_type == Fl_File_Chooser::CREATE) - fc->ok_label ("Save"); + fc.ok_label ("Save"); - fc->show (); + fc.show (); - while (fc->shown ()) + while (fc.shown ()) Fl::wait (); - retval(0) = octave_value(0); - retval(1) = octave_value(0); - retval(2) = octave_value(0); - - if (fc->value()) + if (fc.value()) { - int file_count = fc->count (); + int file_count = fc.count (); std::string fname; std::string sep = file_ops::dir_sep_str (); std::size_t idx; if (file_count == 1 && multi_type != Fl_File_Chooser::DIRECTORY) { - fname = fc->value (); + fname = fc.value (); idx = fname.find_last_of (sep); retval(0) = fname.substr (idx + 1); } @@ -108,7 +106,7 @@ Cell file_cell = Cell(file_count, 1); for (octave_idx_type n = 1; n <= file_count; n++) { - fname = fc->value (n); + fname = fc.value (n); idx = fname.find_last_of (sep); file_cell(n - 1) = fname.substr (idx + 1); } @@ -116,17 +114,16 @@ } if (multi_type == Fl_File_Chooser::DIRECTORY) - retval(0) = std::string (fc->value ()); + retval(0) = std::string (fc.value ()); else { - retval(1) = std::string (fc->directory ()) + sep; - retval(2) = fc->filter_value () + 1; + retval(1) = std::string (fc.directory ()) + sep; + retval(2) = fc.filter_value () + 1; } } - fc->hide (); + fc.hide (); Fl::flush (); - delete fc; return retval; }