Fixed image device error handling [ShimaPong, Miodrag Milanovic]

This commit is contained in:
Miodrag Milanovic 2010-08-04 07:49:46 +00:00
parent 7543a1a9a4
commit 2301c7d1e5
3 changed files with 28 additions and 32 deletions

View File

@ -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)
{
image_error_t err;
UINT32 open_plan[4];
int i;
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;
/* record the filename */
err = set_image_filename(path);
if (err)
m_err = set_image_filename(path);
if (m_err)
goto done;
/* 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++)
{
/* open the file */
err = load_image_by_path(open_plan[i], path);
if (err && (err != IMAGE_ERROR_FILENOTFOUND))
m_err = load_image_by_path(open_plan[i], path);
if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND))
goto done;
}
}
@ -392,8 +391,8 @@ bool legacy_image_device_base::load_internal(const char *path, bool is_create, i
/* did we fail to find the file? */
if (!is_loaded() && !softload)
{
err = IMAGE_ERROR_FILENOTFOUND;
{
m_err = IMAGE_ERROR_FILENOTFOUND;
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;
if (m_init_phase==FALSE) {
err = (image_error_t)finish_load();
if (err)
m_err = (image_error_t)finish_load();
if (m_err)
goto done;
}
/* success! */
done:
if (m_err) {
if (m_err!=0) {
if (!m_init_phase)
{
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;
}
@ -606,4 +605,4 @@ void legacy_image_device_base::call_get_devices()
void *legacy_image_device_base::get_device_specific_call()
{
return (void*) m_config.get_legacy_config_fct(DEVINFO_FCT_DEVICE_SPECIFIC);
}
}

View File

@ -271,9 +271,8 @@ const image_device_format *device_image_interface::device_get_named_creatable_fo
void device_image_interface::clear_error()
{
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();
}
}
@ -284,22 +283,21 @@ void device_image_interface::clear_error()
error - returns the error text for an image
error
-------------------------------------------------*/
static const char *const messages[] =
{
"",
"Internal error",
"Unsupported operation",
"Out of memory",
"File not found",
"Invalid image",
"File already open",
"Unspecified error"
};
const char *device_image_interface::error()
{
static const char *const messages[] =
{
NULL,
"Internal error",
"Unsupported operation",
"Out of memory",
"File not found",
"Invalid image",
"File already open",
"Unspecified error"
};
return m_err_message.len()==0 ? m_err_message : astring(messages[m_err]);
return (m_err_message.len()!=0) ? m_err_message.cstr() : messages[m_err];
}

View File

@ -225,16 +225,15 @@ void image_device_init(running_machine *machine)
if (result)
{
/* retrieve image error message */
const char *image_err = image->error();
astring image_err = astring(image->error());
const char *image_basename_str = image->basename();
/* unload all images */
image_unload_all(*machine);
fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s",
image->image_config().devconfig().name(),
image_basename_str,
image_err);
image_err.cstr());
}
}
else
@ -267,7 +266,7 @@ void image_postdevice_init(running_machine *machine)
if (result)
{
/* retrieve image error message */
const char *image_err = image->error();
astring image_err = astring(image->error());
const char *image_basename_str = image->basename();
/* 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",
image->image_config().devconfig().name(),
image_basename_str,
image_err);
image_err.cstr());
}
}