From: Jürgen Spitzmüller Date: Fri, 24 Jul 2009 07:43:04 +0000 (+0000) Subject: * paragraph_funcs.cpp: sanitize setLabelWidthStringToSequence. Patch by rgheck. X-Git-Tag: 2.0.0~5911 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a18d18fecb37bb178bba0689238494cff0169aaa;p=features.git * paragraph_funcs.cpp: sanitize setLabelWidthStringToSequence. Patch by rgheck. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30759 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/paragraph_funcs.cpp b/src/paragraph_funcs.cpp index d299fc8cdd..cb628992a7 100644 --- a/src/paragraph_funcs.cpp +++ b/src/paragraph_funcs.cpp @@ -256,22 +256,21 @@ bool isFirstInSequence(pit_type par_offset, ParagraphList const & pars) } -void setLabelWidthStringToSequence(pit_type par_offset, +void setLabelWidthStringToSequence(pit_type const par_offset, ParagraphList & pars, docstring const & s) { - Paragraph & par = pars[par_offset]; + pit_type offset = par_offset; // Find first of same layout in sequence - while (!isFirstInSequence(par_offset, pars)) { - par_offset = depthHook(par_offset, pars, par.getDepth()); - par = pars[par_offset]; + while (!isFirstInSequence(offset, pars)) { + offset = depthHook(offset, pars, pars[offset].getDepth()); } // now apply label width string to every par // in sequence pit_type const end = pars.size(); - depth_type const depth = par.getDepth(); - Layout const & layout = par.layout(); - for (pit_type pit = par_offset; pit != end; ++pit) { + depth_type const depth = pars[offset].getDepth(); + Layout const & layout = pars[offset].layout(); + for (pit_type pit = offset; pit != end; ++pit) { while (pars[pit].getDepth() > depth) ++pit; if (pars[pit].getDepth() < depth) diff --git a/src/paragraph_funcs.h b/src/paragraph_funcs.h index 067ba94ba1..33e9a3766b 100644 --- a/src/paragraph_funcs.h +++ b/src/paragraph_funcs.h @@ -63,7 +63,7 @@ bool isFirstInSequence(pit_type par, ParagraphList const & plist); /** Set Label Width string to all paragraphs of the same layout and depth in a sequence */ -void setLabelWidthStringToSequence(pit_type par_offset, +void setLabelWidthStringToSequence(pit_type const par_offset, ParagraphList & pars, docstring const & s); /** Check if the current paragraph is the last paragraph in a