Andre Poenitz wrote:
Does anybody remember why we use a shared pointer and not an index into
the global list of textclasses?
Yes, that was my doing. It used to be a list of textclasses, when these
were static objects. But now the textclasses that are in use are dynamic
objects: They get changed as modules are loaded and unloaded. The shared
pointer is there because of the following situation: You cut some text,
and then close the document. The textclass needs to stay with the cut
text, so it can't just live with the document.
Now we could have some global list of dynamic text classes, and Abdel
suggested this possibility after I'd already implemented it the other
way. The only downside to this is that it might waste memory. You don't
have to keep the textclasses around forever; only so long as something's
using them. So if you had the global list and opened a document, and
then loaded a module, you'd have two entries in the global list, since
you can't tell (or, at least, it's very hard to tell) whether some bit
of cut text has a reference to the old one. And if you do this a few
times, you can end up with several of these lying around.
Now they're probably not all that huge, so maybe that doesn't matter so
much. But that was my thinking at the time.
rh