From 4150a3cd54a43dd220458651fda9537ae1f28e5c Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sat, 6 Nov 2021 20:34:39 +0100 Subject: [PATCH] cc_frm_button.cpp: dont create cc_btn_icon_obj with empty cc_btn_icon, avoid segfault with doble delete - delete cc_btn_icon_obj and CComponentsForm::clear() Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/07f8d789fa17bae234418a7904ca6d5e4b5a0c89 Author: Jacek Jendrzej Date: 2021-11-06 (Sat, 06 Nov 2021) Origin message was: ------------------ cc_frm_button.cpp: dont create cc_btn_icon_obj with empty cc_btn_icon, avoid segfault with doble delete - delete cc_btn_icon_obj and CComponentsForm::clear() --- src/gui/components/cc_frm_button.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index 09688b659..6c315b3a2 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -157,13 +157,17 @@ void CComponentsButton::initIcon() int y_icon = height/2 - h_icon/2; //init icon object - if (cc_btn_icon_obj == NULL){ - cc_btn_icon_obj = new CComponentsPicture(fr_thickness, y_icon, cc_btn_icon, this); - cc_btn_icon_obj->SetTransparent(CFrameBuffer::TM_BLACK); - cc_btn_icon_obj->doPaintBg(false); + if(!cc_btn_icon.empty()) + { + if (cc_btn_icon_obj == NULL) + { + cc_btn_icon_obj = new CComponentsPicture(fr_thickness, y_icon, cc_btn_icon, this); + cc_btn_icon_obj->SetTransparent(CFrameBuffer::TM_BLACK); + cc_btn_icon_obj->doPaintBg(false); + } + cc_btn_icon_obj->setHeight(h_icon, true); + cc_btn_icon_obj->setPicture(cc_btn_icon); } - cc_btn_icon_obj->setHeight(h_icon, true); - cc_btn_icon_obj->setPicture(cc_btn_icon); } void CComponentsButton::initCaption()