[Libreoffice] [PUSHED] Re: [Patch] Cppcheck cleaning on dbaccess

Caolán McNamara caolanm at redhat.com
Sat Jan 15 09:16:01 PST 2011


On Sat, 2011-01-15 at 00:03 +0100, Julien Nabet wrote:
> Hello,
> 
> Here is a small patch for  Cppcheck cleaning on dbaccess

Looks good, pushed, thanks for this.

> Question :
> In the last "git-updated" cppcheck I use, i found this in core part of 
> dbaccess :
> [./api/query.cxx:310]: (error) instance of "OAutoActionReset" object 
> destroyed immediately


> I took a look and I don't understand what's the use of this class.
> in query.cxx, we have this :

> Could someone explain the meaning of all this ?

Well, first off, if
OAutoActionReset(this);
is changed to 
OAutoActionReset aResetter(this);
does the warning go away ?

I believe the intent is that an OAutoActionReset will set
m_eDoingCurrently to NONE in its dtor, so the idea is that when an
OAutoActionReset goes out of scope that dtor gets called, which would
mean that m_eDoingCurrently gets reset after the "if" ends in the normal
course of things.

*Or* if an exception is thrown, seeing as dtors are called when an
exception is thrown, which is probably the real meat of the construct,
i.e. "make sure to reset m_eDoingCurrently to NONE when this scope ends
whether on epic failure or not"

C.



More information about the LibreOffice mailing list