From b32ce853e79684ca842bd677ca6e7e9519858394 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Mon, 14 Nov 2016 04:17:53 +0100 Subject: [PATCH] Fix possible stack overflow Why did this never happen before??! --- Aquaria/ModSelector.cpp | 6 ++++-- Aquaria/ModSelector.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Aquaria/ModSelector.cpp b/Aquaria/ModSelector.cpp index 8d04ee9..a06b3a1 100644 --- a/Aquaria/ModSelector.cpp +++ b/Aquaria/ModSelector.cpp @@ -399,7 +399,7 @@ void JuicyProgressBar::progress(float p) } BasicIcon::BasicIcon() -: mouseDown(false), scaleNormal(1,1), scaleBig(scaleNormal * 1.1f) +: mouseDown(false), scaleNormal(1,1), scaleBig(scaleNormal * 1.1f), _isRecCall(false) { // HACK: Because AquariaMenuItem assigns onClick() in it's ctor, // but we handle this ourselves. @@ -426,7 +426,7 @@ void BasicIcon::onUpdate(float dt) AquariaMenuItem::onUpdate(dt); // Autoscroll if selecting icon outside of screen - if(hasFocus() && dsq->modSelectorScr) + if(hasFocus() && dsq->modSelectorScr && !_isRecCall) { Vector pos = getRealPosition(); if(pos.y < 20 || pos.y > 580) @@ -435,7 +435,9 @@ void BasicIcon::onUpdate(float dt) dsq->modSelectorScr->move(5, true); else dsq->modSelectorScr->move(-5, true); + _isRecCall = true; core->run(FRAME_TIME); // HACK: this is necessary to correctly position the mouse on the object after moving the panel + _isRecCall = false; setFocus(true); // re-position mouse } } diff --git a/Aquaria/ModSelector.h b/Aquaria/ModSelector.h index abb5a97..6aff3dd 100644 --- a/Aquaria/ModSelector.h +++ b/Aquaria/ModSelector.h @@ -39,6 +39,7 @@ protected: bool mouseDown; Vector scaleNormal; Vector scaleBig; + bool _isRecCall; virtual void onUpdate(float dt); virtual void onClick(); };