From 38b44ae386fcd47495c186feb30f654a625ba233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 23 Oct 2014 15:32:31 +0200 Subject: [PATCH] only normalize component bounds in layout_element::layout_element() when components exist (nw) avoids division by zero for sets using src/emu/layout/vertical.lay --- src/emu/rendlay.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/emu/rendlay.c b/src/emu/rendlay.c index 97342836972..2f9393180e1 100644 --- a/src/emu/rendlay.c +++ b/src/emu/rendlay.c @@ -452,19 +452,22 @@ layout_element::layout_element(running_machine &machine, xml_data_node &elemnode m_maxstate = 65536; } - // determine the scale/offset for normalization - float xoffs = bounds.x0; - float yoffs = bounds.y0; - float xscale = 1.0f / (bounds.x1 - bounds.x0); - float yscale = 1.0f / (bounds.y1 - bounds.y0); - - // normalize all the component bounds - for (component *curcomp = m_complist.first(); curcomp != NULL; curcomp = curcomp->next()) + if (m_complist.first() != NULL) { - curcomp->m_bounds.x0 = (curcomp->m_bounds.x0 - xoffs) * xscale; - curcomp->m_bounds.x1 = (curcomp->m_bounds.x1 - xoffs) * xscale; - curcomp->m_bounds.y0 = (curcomp->m_bounds.y0 - yoffs) * yscale; - curcomp->m_bounds.y1 = (curcomp->m_bounds.y1 - yoffs) * yscale; + // determine the scale/offset for normalization + float xoffs = bounds.x0; + float yoffs = bounds.y0; + float xscale = 1.0f / (bounds.x1 - bounds.x0); + float yscale = 1.0f / (bounds.y1 - bounds.y0); + + // normalize all the component bounds + for (component *curcomp = m_complist.first(); curcomp != NULL; curcomp = curcomp->next()) + { + curcomp->m_bounds.x0 = (curcomp->m_bounds.x0 - xoffs) * xscale; + curcomp->m_bounds.x1 = (curcomp->m_bounds.x1 - xoffs) * xscale; + curcomp->m_bounds.y0 = (curcomp->m_bounds.y0 - yoffs) * yscale; + curcomp->m_bounds.y1 = (curcomp->m_bounds.y1 - yoffs) * yscale; + } } // allocate an array of element textures for the states