From 6843ce1c3a8aa044e8e9b630a10a43f70f071ec0 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Mon, 20 May 2024 16:28:11 +0800 Subject: [PATCH] ENH:add log for text to image by font jira: STUDIO-7101 Change-Id: I0765cc6d0ee2992cca68ba657d2987cd54b5bd7c --- src/slic3r/GUI/GLTexture.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/slic3r/GUI/GLTexture.cpp b/src/slic3r/GUI/GLTexture.cpp index 5e9a6e894..75ec59ee8 100644 --- a/src/slic3r/GUI/GLTexture.cpp +++ b/src/slic3r/GUI/GLTexture.cpp @@ -518,6 +518,10 @@ bool GLTexture::generate_from_text(const std::string &text_str, wxFont &font, wx // prepare buffer std::vector data(4 * m_width * m_height, 0); const unsigned char* src = image.GetData(); + if (!src) { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":font ConvertToImage error:\n" << text_str << "," << font.GetBaseFont().GetNativeFontInfoDesc().ToStdString(); + return false; + } /* for debug use std::ofstream fout; fout.open(text_str+std::to_string(m_width)+"_"+std::to_string(m_height)+".rgb", std::ios::out); @@ -596,6 +600,10 @@ bool GLTexture::generate_texture_from_text(const std::string& text_str, wxFont& // prepare buffer std::vector data(4 * m_width * m_height, 0); const unsigned char* src = image.GetData(); + if (!src) { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":font ConvertToImage error:\n" << text_str << "," << font.GetBaseFont().GetNativeFontInfoDesc().ToStdString(); + return false; + } /* for debug use std::ofstream fout; fout.open(text_str+std::to_string(m_width)+"_"+std::to_string(m_height)+".rgb", std::ios::out); @@ -724,6 +732,7 @@ bool GLTexture::load_from_png(const std::string& filename, bool use_mipmaps, ECo unsigned char* img_rgb = image.GetData(); if (img_rgb == nullptr) { reset(); + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":load_from_png error\n"; return false; }