Dekel Tsur <[EMAIL PROTECTED]> writes:
| On Mon, Aug 28, 2000 at 11:43:24AM +0200, Lars Gullik Bjønnes wrote:
| > Dekel Tsur <[EMAIL PROTECTED]> writes:
| >
| > | What is the purpose of the StrPool in Menubar_pimpl.C ?
| > | Can't we use
| > | fl_addtopup(menu, label.c_str());
| > | instead of
| > | fl_addtopup(menu, strpool.add(label)); ?
| >
| > Eh... no, at least at some point in time tat was not possible.
| >
| > The string returned by std::string::c_str is invalidated after any
| > further operations on the std::string. And since fl_addpup only stores
| > a pointer to the c-string we have to keep it around. That is what we
| > use the string pool for.
|
| Look at the following code from the old menu code
|
| for (LastFiles::const_iterator cit = lastfiles->begin();
| cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
| string tmp = tostr(ii);
| tmp += ". " + MakeDisplayPath((*cit), 30);
| fl_addtopup(FileMenu, tmp.c_str());
| }
That this works could be just luck.
| Since this code works, it appears that fl_addtopup creates an internal
| copy of the string, which means that we don't need the string pool.
We should check this with XForms documentation and/or the xforms
mailinglist.
Lgb