It seems to me that the BufferParams may be applied to the core twice
in this block of code. Why don't we apply it once and then see if the
textclass can be switched (if so desired)? Or does switching
textclass mean that we really *do* have to apply it twice?

Angus (who is thinking of LFUN_SET_BUFFERPARAMS)

void ControlDocument::apply()
{
        ...

        classApply();

        buffer()->params() = *bp_;

        ...
}

void ControlDocument::classApply()
{
        BufferParams & params = buffer()->params();
        lyx::textclass_type const old_class = params.textclass;
        lyx::textclass_type const new_class = bp_->textclass;

        // Exit if unable to change the class.
        if (new_class == old_class || !loadTextclass(new_class))
                return;

        // Loaded successfully. Proceed.
        buffer()->params() = *bp_;

        lv_.message(_("Converting document to new document class..."));

        ErrorList el;
        lyx::cap::SwitchLayoutsBetweenClasses(old_class, new_class,
                                                 lv_.buffer()->paragraphs(),
                                                 el);
        bufferErrors(*buffer(), el);
        bufferview()->showErrorList(_("Class switch"));
}


Reply via email to