On 01/28/2010 10:19 AM, Jürgen Spitzmüller wrote:
Abdelrazak Younes wrote:
+ if (oldname != newname) {
+ // adapt the references
+ for (InsetIterator itt =
inset_iterator_begin(in);
+ itt != i_end; ++itt) {
+ if (itt->lyxCode() == REF_CODE)
{
+ InsetCommand& ref =
+
dynamic_cast<InsetCommand&>(*itt);
I don't think you need a dynamic cast. And if you need it, you should
use a pointer instead and check it id null.
I just copied the code from the label mechanism below. Frankly, I no next to
nothing about those *_casts. What do you suggest?
A static cast:
static_cast<InsetCommand&> or static_cast<InsetCommand *>
A static cast is OK here because we are sure that this is indeed an
InsetCommand. Dynamic casts are in general used in case of multiple
inheritance. It's a runtime thing and thus slower than a static cast
which is done at compilation time.
and
if (itt->lyxCode() != REF_CODE)
continue;
I'll need a second condition for the MATH_REF_CODE (bug 1562), so I left this.
(that's why I didn't change trunk yet; I'll commit the indentation changes
with that patch)
OK, thanks.
Abdel.