From 0abd5bb6d75e677945d33e0ade30dcc0bcb8a4c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Wed, 1 Jul 2020 18:50:49 -0300 Subject: [PATCH] Bad memory access fix. --- src/eepp/ui/uimenucheckbox.cpp | 10 ++++++---- src/eepp/ui/uimenuradiobutton.cpp | 28 +++++++++++++++------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/eepp/ui/uimenucheckbox.cpp b/src/eepp/ui/uimenucheckbox.cpp index b8efbfad2..5d6f4891c 100644 --- a/src/eepp/ui/uimenucheckbox.cpp +++ b/src/eepp/ui/uimenucheckbox.cpp @@ -87,11 +87,13 @@ void UIMenuCheckBox::setActive( const bool& active ) { } if ( oActive != active ) { - UIMenu* Menu = getParent()->asType(); + if ( getParent()->isType( UI_TYPE_MENU ) ) { + UIMenu* menu = getParent()->asType(); - if ( !Menu->widgetCheckSize( this ) ) { - if ( NULL != getIcon()->getDrawable() ) { - setPadding( Rectf( 0, 0, 0, 0 ) ); + if ( !menu->widgetCheckSize( this ) ) { + if ( NULL != getIcon()->getDrawable() ) { + setPadding( Rectf( 0, 0, 0, 0 ) ); + } } } diff --git a/src/eepp/ui/uimenuradiobutton.cpp b/src/eepp/ui/uimenuradiobutton.cpp index 0379aa59e..c29ebf763 100644 --- a/src/eepp/ui/uimenuradiobutton.cpp +++ b/src/eepp/ui/uimenuradiobutton.cpp @@ -92,21 +92,23 @@ void UIMenuRadioButton::setActive( const bool& active ) { } } - UIMenu* Menu = getParent()->asType(); + if ( getParent()->isType( UI_TYPE_MENU ) ) { + UIMenu* menu = getParent()->asType(); - if ( !Menu->widgetCheckSize( this ) ) { - if ( NULL != getIcon()->getDrawable() ) { - setPadding( Rectf( 0, 0, 0, 0 ) ); - } - } - - if ( mActive ) { - Node* child = Menu->getFirstChild(); - while ( child ) { - if ( child->isType( UI_TYPE_MENURADIOBUTTON ) && child != this ) { - child->asType()->setActive( false ); + if ( !menu->widgetCheckSize( this ) ) { + if ( NULL != getIcon()->getDrawable() ) { + setPadding( Rectf( 0, 0, 0, 0 ) ); + } + } + + if ( mActive ) { + Node* child = menu->getFirstChild(); + while ( child ) { + if ( child->isType( UI_TYPE_MENURADIOBUTTON ) && child != this ) { + child->asType()->setActive( false ); + } + child = child->getNextNode(); } - child = child->getNextNode(); } }