mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 14:41:50 +00:00
saver: ++robustness
do not delete the given picture if the reference counting is more than 0.
This commit is contained in:
parent
0c602291cb
commit
a741778dab
1 changed files with 4 additions and 3 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "tvgCommon.h"
|
||||
#include "tvgSaveModule.h"
|
||||
#include "tvgPaint.h"
|
||||
|
||||
#ifdef THORVG_TVG_SAVER_SUPPORT
|
||||
#include "tvgTvgSaver.h"
|
||||
|
@ -123,7 +124,7 @@ Result Saver::save(unique_ptr<Paint> paint, const string& path, uint32_t quality
|
|||
|
||||
//Already on saving an other resource.
|
||||
if (pImpl->saveModule) {
|
||||
delete(p);
|
||||
if (P(p)->refCnt == 0) delete(p);
|
||||
return Result::InsufficientCondition;
|
||||
}
|
||||
|
||||
|
@ -132,12 +133,12 @@ Result Saver::save(unique_ptr<Paint> paint, const string& path, uint32_t quality
|
|||
pImpl->saveModule = saveModule;
|
||||
return Result::Success;
|
||||
} else {
|
||||
delete(p);
|
||||
if (P(p)->refCnt == 0) delete(p);
|
||||
delete(saveModule);
|
||||
return Result::Unknown;
|
||||
}
|
||||
}
|
||||
delete(p);
|
||||
if (P(p)->refCnt == 0) delete(p);
|
||||
return Result::NonSupport;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue