mirror of
https://github.com/holub/mame
synced 2025-05-30 17:41:47 +03:00
Merge pull request #1490 from npwoods/imgtool_bug_fix
[Imgtool] Fixed a recently introduced bug
This commit is contained in:
commit
bb78203617
@ -1024,7 +1024,9 @@ imgtoolerr_t imgtool::image::internal_open(const imgtool_module *module, const c
|
||||
goto done;
|
||||
}
|
||||
|
||||
// we've succeeded - set the output image
|
||||
// we've succeeded - set the output image, and record that
|
||||
// we are "okay to close"
|
||||
image->m_okay_to_close = true;
|
||||
outimg = std::move(image);
|
||||
|
||||
done:
|
||||
@ -1072,6 +1074,7 @@ imgtool::image::image(const imgtool_module &module, object_pool *pool, void *ext
|
||||
: m_module(module)
|
||||
, m_pool(pool)
|
||||
, m_extra_bytes(extra_bytes)
|
||||
, m_okay_to_close(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1082,7 +1085,7 @@ imgtool::image::image(const imgtool_module &module, object_pool *pool, void *ext
|
||||
|
||||
imgtool::image::~image()
|
||||
{
|
||||
if (module().close)
|
||||
if (m_okay_to_close && module().close)
|
||||
module().close(this);
|
||||
pool_free_lib(m_pool);
|
||||
}
|
||||
|
@ -123,6 +123,11 @@ namespace imgtool
|
||||
object_pool *m_pool;
|
||||
void *m_extra_bytes;
|
||||
|
||||
// because of an idiosycracy of how imgtool::image::internal_open() works, we are only "okay to close"
|
||||
// by invoking the module's close function once internal_open() succeeds. the long term solution is
|
||||
// better C++ adoption (e.g. - std::unique_ptr<>, std:move() etc)
|
||||
bool m_okay_to_close;
|
||||
|
||||
static imgtoolerr_t internal_open(const imgtool_module *module, const char *fname,
|
||||
int read_or_write, util::option_resolution *createopts, imgtool::image::ptr &outimg);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user