From 2fa7e372c6ac358eeb60f9fdd779869ab0b09551 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 18 Dec 2016 18:48:02 +0100 Subject: [PATCH] CComponentsHeader: ensure to have correct font instances after changed font On possible changed font settings, font objects can be invalid and we have a crash. With this fix it's possible, that CNeutrinoApp::setupFont() method clean up header font object itself. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/239496c207d67074646389cf0b105251d3103a2f Author: Thilo Graf Date: 2016-12-18 (Sun, 18 Dec 2016) ------------------ This commit was generated by Migit --- src/gui/components/cc_frm_header.cpp | 10 +++++++++- src/gui/components/cc_frm_header.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index 5a6e3ec74..a3e26b90e 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -97,6 +97,7 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const cch_font = NULL; cch_size_mode = CC_HEADER_SIZE_LARGE; + CNeutrinoApp::getInstance()->OnAfterSetupFonts.connect(sigc::mem_fun(this, &CComponentsHeader::resetFont)); shadow = shadow_mode; col_frame = col_frame_old = color_frame; @@ -161,6 +162,14 @@ void CComponentsHeader::setCaptionFont(Font* font) cch_font = font; } +void CComponentsHeader::resetFont() +{ + if (cch_font){ + cch_font = NULL; + dprintf(DEBUG_DEBUG, "\033[33m[CComponentsHeader][%s - %d] reset header font \033[0m\n", __func__, __LINE__); + } +} + void CComponentsHeader::initCaptionFont() { Font *l_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; @@ -168,7 +177,6 @@ void CComponentsHeader::initCaptionFont() if (cch_font == NULL){ cch_font = (cch_size_mode == CC_HEADER_SIZE_LARGE? l_font : s_font); - //select matching height if (cch_size_mode == CC_HEADER_SIZE_LARGE) height = std::max(height, l_font->getHeight()); diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h index d091e800f..6d3169c12 100644 --- a/src/gui/components/cc_frm_header.h +++ b/src/gui/components/cc_frm_header.h @@ -68,6 +68,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen fb_pixel_t cch_col_text; ///property: caption font, see also setCaptionFont() Font* cch_font; + ///reset font + void resetFont(); ///property: internal y-position for all items int cch_items_y;