diff --git a/src/client/guiscalingfilter.cpp b/src/client/guiscalingfilter.cpp index fda525e3f..fcfae5022 100644 --- a/src/client/guiscalingfilter.cpp +++ b/src/client/guiscalingfilter.cpp @@ -78,6 +78,7 @@ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver, { if (src == NULL) return src; + if (!g_settings->getBool("gui_scaling_filter")) return src; @@ -114,6 +115,14 @@ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver, // Create a new destination image and scale the source into it. imageCleanTransparent(srcimg, 0); + + if (destrect.getWidth() <= 0 || destrect.getHeight() <= 0) { + errorstream << "Attempted to scale texture to invalid size " << scalename.c_str() << std::endl; + // Avoid log spam by reusing and displaying the original texture + src->grab(); + g_txrCache[scalename] = src; + return src; + } video::IImage *destimg = driver->createImage(src->getColorFormat(), core::dimension2d((u32)destrect.getWidth(), (u32)destrect.getHeight())); @@ -160,6 +169,10 @@ void draw2DImageFilterScaled(video::IVideoDriver *driver, video::ITexture *txr, const core::rect *cliprect, const video::SColor *const colors, bool usealpha) { + // 9-sliced images might calculate negative texture dimensions. Skip them. + if (destrect.getWidth() <= 0 || destrect.getHeight() <= 0) + return; + // Attempt to pre-scale image in software in high quality. video::ITexture *scaled = guiScalingResizeCached(driver, txr, srcrect, destrect); if (scaled == NULL)