Hi
If a destructor called during stack unwinding throws an exception, then C++
guarantees the process will be killed by calling terminate()
https://isocpp.org/wiki/faq/exceptions#dtors-shouldnt-throw
http://stackoverflow.com/questions/5798107/c-throwing-an-exception-from-a-destructor
That means any code like this terminates the process, instead of reporting an
exception:
Try
{
PdfPainter painter;
Painter.SetPage( pCanvas ));
// calls PODOFO_RAISE_ERROR because gray out of range,
// but could be any PoDoFo method that raises an exception
PdfPainter:: SetStrokingGray( 1.1 );
// never reaches here if an exception is thrown
Painter.FinishPage();
}
catch ( PoDoFo::PdfError& error )
{
// ~PdfPainter is called before handling this, but FinishPaint hasn’t
been called
// so ~PdfPainter throws an exception, which then terminates the
application
// because an exception is already being handled
error.PrintErrorMsg();
}
If an exception isn’t being handled when ~ PdfPainter throws an exception
then:
- the behavior is undocumented
- throwing in the destructor when destroying an array or collection of
PdfPainters means some destructors are never called
Best Regards
Mark
Mark Rogers - [email protected]
PowerMapper Software Ltd - www.powermapper.com
Registered in Scotland No 362274 Quartermile 2 Edinburgh EH3 9GL
On 22/01/2017, 11:02, "zyx" <[email protected]> wrote:
On 20.1.2017 20:49, Mark Rogers wrote:
> There‘s a problem in release builds. PdfPainter::~PdfPainter throws
> exceptions in release builds because PODOFO_ASSERT throws exceptions
> via PODOFO_RAISE_ERROR_INFO in release builds
Hi,
that's after one of my changes.
> if( m_pCanvas ) PdfError::LogMessage( eLogSeverity_Error,
> "PdfPainter::~PdfPainter(): FinishPage() has to be called after a
> page is completed!" );
Are you sure you call the FinishPage() before the PdfPainter is
destroyed? The error suggests that it's not done, but it should be.
Alternatively, if you face this in any of the PoDoFo examples or tools,
then they are supposed to be fixed.
In other words, I believe that this error is valid and should not be
muted for non-debug builds.
Bye,
zyx
--
http://www.litePDF.cz [email protected]
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users