Result Saver::save(std::unique_ptr<Paint> paint, const string& path, bool compress) noexcept
{
- //Already on saving an other resource.
- if (pImpl->saveModule) return Result::InsufficientCondition;
-
auto p = paint.release();
if (!p) return Result::MemoryCorruption;
+ //Already on saving an other resource.
+ if (pImpl->saveModule) {
+ delete(p);
+ return Result::InsufficientCondition;
+ }
+
if (auto saveModule = _find(path)) {
if (saveModule->save(p, path, compress)) {
pImpl->saveModule = saveModule;
{
close();
- this->path = strdup(path.c_str());
- if (!this->path) return false;
-
float x, y;
x = y = 0;
paint->bounds(&x, &y, &vsize[0], &vsize[1], false);
return false;
}
+ this->path = strdup(path.c_str());
+ if (!this->path) return false;
+
this->paint = paint;
this->compress = compress;