mirror of
https://github.com/holub/mame
synced 2025-06-30 16:00:01 +03:00
Fixed image device error handling [ShimaPong, Miodrag Milanovic]
This commit is contained in:
parent
7543a1a9a4
commit
2301c7d1e5
@ -345,7 +345,6 @@ bool legacy_image_device_base::load_software(char *swlist, char *swname, rom_ent
|
|||||||
|
|
||||||
bool legacy_image_device_base::load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args)
|
bool legacy_image_device_base::load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args)
|
||||||
{
|
{
|
||||||
image_error_t err;
|
|
||||||
UINT32 open_plan[4];
|
UINT32 open_plan[4];
|
||||||
int i;
|
int i;
|
||||||
bool softload = FALSE;
|
bool softload = FALSE;
|
||||||
@ -360,8 +359,8 @@ bool legacy_image_device_base::load_internal(const char *path, bool is_create, i
|
|||||||
m_is_loading = TRUE;
|
m_is_loading = TRUE;
|
||||||
|
|
||||||
/* record the filename */
|
/* record the filename */
|
||||||
err = set_image_filename(path);
|
m_err = set_image_filename(path);
|
||||||
if (err)
|
if (m_err)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Check if there's a software list defined for this device and use that if we're not creating an image */
|
/* Check if there's a software list defined for this device and use that if we're not creating an image */
|
||||||
@ -375,8 +374,8 @@ bool legacy_image_device_base::load_internal(const char *path, bool is_create, i
|
|||||||
for (i = 0; !m_file && open_plan[i]; i++)
|
for (i = 0; !m_file && open_plan[i]; i++)
|
||||||
{
|
{
|
||||||
/* open the file */
|
/* open the file */
|
||||||
err = load_image_by_path(open_plan[i], path);
|
m_err = load_image_by_path(open_plan[i], path);
|
||||||
if (err && (err != IMAGE_ERROR_FILENOTFOUND))
|
if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND))
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -393,7 +392,7 @@ bool legacy_image_device_base::load_internal(const char *path, bool is_create, i
|
|||||||
/* did we fail to find the file? */
|
/* did we fail to find the file? */
|
||||||
if (!is_loaded() && !softload)
|
if (!is_loaded() && !softload)
|
||||||
{
|
{
|
||||||
err = IMAGE_ERROR_FILENOTFOUND;
|
m_err = IMAGE_ERROR_FILENOTFOUND;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,14 +401,14 @@ bool legacy_image_device_base::load_internal(const char *path, bool is_create, i
|
|||||||
m_create_args = create_args;
|
m_create_args = create_args;
|
||||||
|
|
||||||
if (m_init_phase==FALSE) {
|
if (m_init_phase==FALSE) {
|
||||||
err = (image_error_t)finish_load();
|
m_err = (image_error_t)finish_load();
|
||||||
if (err)
|
if (m_err)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* success! */
|
/* success! */
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (m_err) {
|
if (m_err!=0) {
|
||||||
if (!m_init_phase)
|
if (!m_init_phase)
|
||||||
{
|
{
|
||||||
if (machine->phase() == MACHINE_PHASE_RUNNING)
|
if (machine->phase() == MACHINE_PHASE_RUNNING)
|
||||||
@ -434,7 +433,7 @@ done:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS;
|
return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,9 +271,8 @@ const image_device_format *device_image_interface::device_get_named_creatable_fo
|
|||||||
void device_image_interface::clear_error()
|
void device_image_interface::clear_error()
|
||||||
{
|
{
|
||||||
m_err = IMAGE_ERROR_SUCCESS;
|
m_err = IMAGE_ERROR_SUCCESS;
|
||||||
if (m_err_message.len()==0)
|
if (m_err_message.len()!=0)
|
||||||
{
|
{
|
||||||
//image_freeptr(image->dev, image->err_message);
|
|
||||||
m_err_message.reset();
|
m_err_message.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,12 +283,9 @@ void device_image_interface::clear_error()
|
|||||||
error - returns the error text for an image
|
error - returns the error text for an image
|
||||||
error
|
error
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
static const char *const messages[] =
|
||||||
const char *device_image_interface::error()
|
|
||||||
{
|
{
|
||||||
static const char *const messages[] =
|
"",
|
||||||
{
|
|
||||||
NULL,
|
|
||||||
"Internal error",
|
"Internal error",
|
||||||
"Unsupported operation",
|
"Unsupported operation",
|
||||||
"Out of memory",
|
"Out of memory",
|
||||||
@ -297,9 +293,11 @@ const char *device_image_interface::error()
|
|||||||
"Invalid image",
|
"Invalid image",
|
||||||
"File already open",
|
"File already open",
|
||||||
"Unspecified error"
|
"Unspecified error"
|
||||||
};
|
};
|
||||||
|
|
||||||
return m_err_message.len()==0 ? m_err_message : astring(messages[m_err]);
|
const char *device_image_interface::error()
|
||||||
|
{
|
||||||
|
return (m_err_message.len()!=0) ? m_err_message.cstr() : messages[m_err];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -225,16 +225,15 @@ void image_device_init(running_machine *machine)
|
|||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
/* retrieve image error message */
|
/* retrieve image error message */
|
||||||
const char *image_err = image->error();
|
astring image_err = astring(image->error());
|
||||||
const char *image_basename_str = image->basename();
|
const char *image_basename_str = image->basename();
|
||||||
|
|
||||||
/* unload all images */
|
/* unload all images */
|
||||||
image_unload_all(*machine);
|
image_unload_all(*machine);
|
||||||
|
|
||||||
fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s",
|
fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s",
|
||||||
image->image_config().devconfig().name(),
|
image->image_config().devconfig().name(),
|
||||||
image_basename_str,
|
image_basename_str,
|
||||||
image_err);
|
image_err.cstr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -267,7 +266,7 @@ void image_postdevice_init(running_machine *machine)
|
|||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
/* retrieve image error message */
|
/* retrieve image error message */
|
||||||
const char *image_err = image->error();
|
astring image_err = astring(image->error());
|
||||||
const char *image_basename_str = image->basename();
|
const char *image_basename_str = image->basename();
|
||||||
|
|
||||||
/* unload all images */
|
/* unload all images */
|
||||||
@ -276,7 +275,7 @@ void image_postdevice_init(running_machine *machine)
|
|||||||
fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s",
|
fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s",
|
||||||
image->image_config().devconfig().name(),
|
image->image_config().devconfig().name(),
|
||||||
image_basename_str,
|
image_basename_str,
|
||||||
image_err);
|
image_err.cstr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user