Annotate destructors to please coverity

Coverity flags this code as not handling exception that may happen in buffer().

My own analysis is that this can never happen because isBufferValid()
does check whether buffer_ is null.

Any insght appreciated. The commit should be expeanded to more cases, actually.
This commit is contained in:
Jean-Marc Lasgouttes 2017-03-27 16:18:14 +02:00
parent 0d6c64a4eb
commit e10db6c7dd
4 changed files with 12 additions and 2 deletions

View File

@ -112,8 +112,8 @@ public:
/// reset associated Buffer to null value /// reset associated Buffer to null value
virtual void resetBuffer(); virtual void resetBuffer();
/// retrieve associated Buffer /// retrieve associated Buffer
virtual Buffer & buffer(); Buffer & buffer();
virtual Buffer const & buffer() const; Buffer const & buffer() const;
/// Returns true if buffer_ actually points to a Buffer that has /// Returns true if buffer_ actually points to a Buffer that has
/// been loaded into LyX and is still open. Note that this will /// been loaded into LyX and is still open. Note that this will
/// always return false for cloned Buffers. If you want to allow /// always return false for cloned Buffers. If you want to allow

View File

@ -68,6 +68,9 @@ InsetBibitem::InsetBibitem(Buffer * buf, InsetCommandParams const & p)
InsetBibitem::~InsetBibitem() InsetBibitem::~InsetBibitem()
{ {
if (isBufferLoaded()) if (isBufferLoaded())
/* Coverity believs that this may throw an exception, but
* actually this code path is not taken when buffer_ == 0 */
// coverity[exn_spec_violation]
buffer().invalidateBibinfoCache(); buffer().invalidateBibinfoCache();
} }

View File

@ -68,7 +68,11 @@ InsetBibtex::InsetBibtex(Buffer * buf, InsetCommandParams const & p)
InsetBibtex::~InsetBibtex() InsetBibtex::~InsetBibtex()
{ {
if (isBufferLoaded()) { if (isBufferLoaded()) {
/* Coverity believs that this may throw an exception, but
* actually this code path is not taken when buffer_ == 0 */
// coverity[exn_spec_violation]
buffer().invalidateBibfileCache(); buffer().invalidateBibfileCache();
// coverity[exn_spec_violation]
buffer().removeBiblioTempFiles(); buffer().removeBiblioTempFiles();
} }
} }

View File

@ -198,6 +198,9 @@ InsetInclude::InsetInclude(InsetInclude const & other)
InsetInclude::~InsetInclude() InsetInclude::~InsetInclude()
{ {
if (isBufferLoaded()) if (isBufferLoaded())
/* Coverity believs that this may throw an exception, but
* actually this code path is not taken when buffer_ == 0 */
// coverity[exn_spec_violation]
buffer().invalidateBibfileCache(); buffer().invalidateBibfileCache();
delete label_; delete label_;
} }