Don't override the FGIMG style property if the image parameter is null
authorHugues Ross <hugues.ross@gmail.com>
Sat, 14 Dec 2019 23:09:27 +0000 (18:09 -0500)
committersfan5 <sfan5@live.de>
Mon, 16 Dec 2019 18:26:57 +0000 (19:26 +0100)
src/gui/guiFormSpecMenu.cpp

index 320608642f8917f92c73339a988613ca1a7d1423..e6cd50d86bb578941509f59a4f4bc95c4d778b16 100644 (file)
@@ -1835,9 +1835,6 @@ void GUIFormSpecMenu::parseImageButton(parserData* data, const std::string &elem
                if (type == "image_button_exit")
                        spec.is_exit = true;
 
-               video::ITexture *texture = 0;
-               texture = m_tsrc->getTexture(image_name);
-
                GUIButtonImage *e = GUIButtonImage::addButton(Environment, rect, this, spec.fid, spec.flabel.c_str());
 
                if (spec.fname == data->focused_fieldname) {
@@ -1849,8 +1846,12 @@ void GUIFormSpecMenu::parseImageButton(parserData* data, const std::string &elem
 
                // We explicitly handle these arguments *after* the style properties in
                // order to override them if they are provided
-               e->setForegroundImage(guiScalingImageButton(
-                       Environment->getVideoDriver(), texture, geom.X, geom.Y));
+               if (!image_name.empty())
+               {
+                       video::ITexture *texture = m_tsrc->getTexture(image_name);
+                       e->setForegroundImage(guiScalingImageButton(
+                               Environment->getVideoDriver(), texture, geom.X, geom.Y));
+               }
                if (!pressed_image_name.empty()) {
                        video::ITexture *pressed_texture = m_tsrc->getTexture(pressed_image_name);
                        e->setPressedForegroundImage(guiScalingImageButton(