On Friday 01 November 2002 10:47 am, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > | As "data" is a static variable, shouldn't this function > | return a reference? > > I'd rather remove the static. > > It makes the funciton non-reentrant for no good reason. > And if it needs to cache anything is should be done as a class > variable not as a static var inside a member function.
Here's the patch. Ok? Angus
? src/frontends/xforms/preferences.h Index: src/frontends/controllers/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v retrieving revision 1.243 diff -u -p -r1.243 ChangeLog --- src/frontends/controllers/ChangeLog 31 Oct 2002 20:05:54 -0000 1.243 +++ src/frontends/controllers/ChangeLog 1 Nov 2002 11:05:01 -0000 @@ -1,7 +1,11 @@ +2002-11-01 Angus Leeming <[EMAIL PROTECTED]> + + * ControlGraphics.[Ch] (getBBUnits): renamed from getUnits and moved + out of the class and into namespace frnt. + 2002-10-31 John Levon <[EMAIL PROTECTED]> - * ControlGraphics.h: - * ControlGraphics.C: bb units from Herbert + * ControlGraphics.[Ch]: bb units from Herbert 2002-10-29 Rob Lahaye <[EMAIL PROTECTED]> Index: src/frontends/controllers/ControlGraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlGraphics.C,v retrieving revision 1.54 diff -u -p -r1.54 ControlGraphics.C --- src/frontends/controllers/ControlGraphics.C 31 Oct 2002 20:05:54 -0000 1.54 +++ src/frontends/controllers/ControlGraphics.C 1 Nov 2002 11:05:01 -0000 @@ -133,32 +133,13 @@ bool ControlGraphics::isFilenameValid(st } -namespace { - -static char const * bb_units[] = { "bp", "cm", "mm", "in"}; -size_t const bb_size = sizeof(bb_units) / sizeof(char *); - -} - - -vector<string> const ControlGraphics::getUnits() -{ - static vector<string> data; - if (!data.empty()) - return data; - - data.resize(bb_size); - for (lyx::size_type i = 0; i < bb_size; ++i) { - data[i] = bb_units[i]; - } - return data; -} - - namespace frnt { namespace { +char const * const bb_units[] = { "bp", "cm", "mm", "in"}; +size_t const bb_size = sizeof(bb_units) / sizeof(char *); + // These are the strings that are stored in the LyX file and which // correspond to the LaTeX identifiers shown in the comments at the // end of each line. @@ -179,6 +160,13 @@ size_t const rorigin_size = sizeof(rorig } // namespace anon + +vector<string> const getBBUnits() +{ + vector<string> data(bb_size); + std::copy(bb_units, bb_units + bb_size, data.begin()); + return data; +} vector<RotationOriginPair> getRotationOriginData() { Index: src/frontends/controllers/ControlGraphics.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlGraphics.h,v retrieving revision 1.16 diff -u -p -r1.16 ControlGraphics.h --- src/frontends/controllers/ControlGraphics.h 31 Oct 2002 20:05:54 -0000 1.16 +++ src/frontends/controllers/ControlGraphics.h 1 Nov 2002 11:05:01 -0000 @@ -47,8 +47,6 @@ public: bool bbChanged; /// test if file exist bool isFilenameValid(string const & fname) const; - /// get the units for the bb - std::vector<string> const getUnits(); private: /// Dispatch the changed parameters to the kernel. @@ -62,6 +60,9 @@ private: }; namespace frnt { + +/// get the units for the bb +vector<string> const getBBUnits(); /// The (tranlated) GUI string and it's LaTeX equivalent. typedef std::pair<string, string> RotationOriginPair; Index: src/frontends/qt2/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v retrieving revision 1.263 diff -u -p -r1.263 ChangeLog --- src/frontends/qt2/ChangeLog 31 Oct 2002 20:45:57 -0000 1.263 +++ src/frontends/qt2/ChangeLog 1 Nov 2002 11:05:01 -0000 @@ -1,3 +1,7 @@ +2002-11-01 Angus Leeming <[EMAIL PROTECTED]> + + * QGraphics.C:: controller.getUnits() is now frnt::getBBUnits(). + 2002-10-31 John Levon <[EMAIL PROTECTED]> * QExternal.C: fix crash, valid check Index: src/frontends/qt2/QGraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QGraphics.C,v retrieving revision 1.16 diff -u -p -r1.16 QGraphics.C --- src/frontends/qt2/QGraphics.C 31 Oct 2002 20:05:54 -0000 1.16 +++ src/frontends/qt2/QGraphics.C 1 Nov 2002 11:05:01 -0000 @@ -114,7 +114,7 @@ int getItemNo(vector<string> v, string c void QGraphics::update_contents() { // clear and fill in the comboboxes - vector<string> const bb_units = controller().getUnits(); + vector<string> const bb_units = frnt::getBBUnits(); dialog_->lbXunit->clear(); dialog_->lbYunit->clear(); dialog_->rtXunit->clear(); Index: src/frontends/xforms/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v retrieving revision 1.592 diff -u -p -r1.592 ChangeLog --- src/frontends/xforms/ChangeLog 31 Oct 2002 11:25:02 -0000 1.592 +++ src/frontends/xforms/ChangeLog 1 Nov 2002 11:05:02 -0000 @@ -1,3 +1,7 @@ +2002-11-01 Angus Leeming <[EMAIL PROTECTED]> + + * FormGraphics.C:: use frnt::getBBUnits(). + 2002-10-31 Rob Lahaye <[EMAIL PROTECTED]> * xformsImage.C (clip): fix crash caused by uint -> int nastiness. Index: src/frontends/xforms/FormGraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormGraphics.C,v retrieving revision 1.89 diff -u -p -r1.89 FormGraphics.C --- src/frontends/xforms/FormGraphics.C 31 Oct 2002 11:25:02 -0000 1.89 +++ src/frontends/xforms/FormGraphics.C 1 Nov 2002 11:05:03 -0000 @@ -183,7 +183,8 @@ void FormGraphics::build() fl_set_input_filter(bbox_->input_bb_y0, fl_unsigned_float_filter); fl_set_input_filter(bbox_->input_bb_y1, fl_unsigned_float_filter); - string const bb_units = "bp|cm|mm|in"; + string const bb_units = + getStringFromVector(frnt::getBBUnits(), "|"); fl_addto_choice(bbox_->choice_bb_units, bb_units.c_str()); // set up the tooltips for the bounding-box-section