On Sat, Aug 25, 2001 at 09:56:49PM +0100, John Levon wrote:
>
> Angus recently added isBuilt() in controllers/ to make sure that
> the dialog is built before changing its readonly stuff.
>
> 60 template <class Base>
> 61 void ControlDialog<Base>::show()
> 62 {
> 63 if (isBufferDependent() && !lv_.view()->available())
> 64 return;
> 65
> 66 setParams();
> 67
> 68 static bool isBuilt = false;
> 69 if (!isBuilt) {
> 70 isBuilt = true;
> 71 view().build();
> 72 }
>
>
> unfortunately, the static seems to be sharing itself with all templatised
> objects. How can we get the expected per-dialog isBuilt() functionality ?
Your void ControlDialog<Base>::show() is common to all objects of type
"Base". Why don't you just use a data member? Rough draft:
template <class Base>
class ControlDialog {
...
private:
...
class State {
public:
bool isBuilt;
State() : isBuilt(false) {}
};
State state_;
};
template <class Base>
void ControlDialog<Base>::show()
{
...
if (!state_.isBuilt) {
state_.isBuilt = true;
...
}
...
}
>
> thanks
> john
>
> --
> "That's just kitten-eating wrong."
> - Richard Henderson
--
Yves