hello,<br><br>I will see this week end. UpdateDocState already check if the stats are updated, so we can run UpdateDocStat all times I think.<br><br>Thanks for the review<br><br><div class="gmail_quote">2011/8/19 Caolán McNamara <span dir="ltr"><<a href="mailto:caolanm@redhat.com">caolanm@redhat.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Wed, 2011-08-17 at 21:04 +0200, Arnaud Versini wrote:<br>
> Hi<br>
><br>
> This patch remove unnecessary parameter SwDocStat& rStat to the method<br>
> IDocumentStatistics::UpdateDocStat and also limit copy of SwDocStat<br>
> during file saving and statistic dialog.<br>
<br>
</div>There's a bug in the last hunk anyway,<br>
<br>
{<br>
SwDocStat aStat(pDocShell->GetDoc()->GetDocStat());<br>
if(aStat.bModified)<br>
- pDocShell->GetDoc()->UpdateDocStat( aStat );<br>
+ pDocShell->GetDoc()->UpdateDocStat();<br>
<br>
i.e. the "aStat" is a copy so after the UpdateDocStat is called, it's an<br>
unchanged copy, not a reference to an updated SwDocStat like it used to<br>
be, so a line or two later nValue = aStat.nChar will be wrong.<br>
<br>
Is there a specific problem you're trying to fix here ?<br>
<br>
Looking through the DocStat stuff it looks a bit messy. Seems of it<br>
appears to want to give access to the document statistics for a fast<br>
query by some code that the stats need to be updated, and by other code<br>
just to get the stats. And some bits fail to check for bModified and<br>
force an update and some do. And the awesome rtf filter const_casts the<br>
document doc stat and updates it directly.<br>
<br>
If we want to refactor this then I suggest...<br>
<br>
a) move "bModified" out of the SwDocStat and add something like bool<br>
areStatsStale/statsNeedUpdating to IDocumentStatistics instead to query<br>
this fact<br>
b) have IDocumentStatistics::GetDocStat always return updated document<br>
stats instead of having to get them, find out if they are stale and<br>
update them if they are.<br>
<br>
That would probably avoid the problems of needing to directly call<br>
UpdateDocStat for the general case where someone just wants to get<br>
up-to-date stats, but allow any special cases of calling UpdateDocStat<br>
when areStatsStale is true in order to force update of fields that<br>
display the doc stats.<br>
<font color="#888888"><br>
C.<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Arnaud Versini<br>