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