From 1ba2ae905ad33f8e311100fd4e9e48653ca4b63d Mon Sep 17 00:00:00 2001 From: louis Date: Tue, 31 Mar 2015 05:34:41 +0200 Subject: [PATCH] fixed bug also for loops --- HISTORY | 2 ++ libtemplate/templateloopfunction.c | 33 ++++++++++++++++++++++++++---- libtemplate/templateloopfunction.h | 4 ++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/HISTORY b/HISTORY index 95deb82..87a712e 100644 --- a/HISTORY +++ b/HISTORY @@ -243,3 +243,5 @@ Version 0.3.3 recordings in main menu - fixed bug that parameters with both dynamic tokens and relative width, height, posx or posy values are not parsed correctly +- fixed bug also for loops + diff --git a/libtemplate/templateloopfunction.c b/libtemplate/templateloopfunction.c index b0030d3..4de9ec4 100644 --- a/libtemplate/templateloopfunction.c +++ b/libtemplate/templateloopfunction.c @@ -95,8 +95,25 @@ void cTemplateLoopFunction::ParseDynamicParameters(map *tokens) return; } - ReplaceWidthFunctions(); - ReplaceHeightFunctions(); + bool replacedWidth = ReplaceWidthFunctions(); + bool replacedHeight = ReplaceHeightFunctions(); + + if (!replacedWidth && !replacedHeight) + return; + + InitIterator(); + func = NULL; + while(func = GetNextFunction()) { + if (func->ParsedCompletely()) + continue; + func->SetStringTokens(tokens); + func->SetIntTokens(&intTokens); + func->ParseParameters(); + if (func->Updated()) + func->CompleteParameters(); + func->UnsetIntTokens(); + func->UnsetStringTokens(); + } } int cTemplateLoopFunction::GetLoopElementsWidth(void) { @@ -132,7 +149,8 @@ int cTemplateLoopFunction::GetLoopElementsHeight(void) { return maxHeight; } -void cTemplateLoopFunction::ReplaceWidthFunctions(void) { +bool cTemplateLoopFunction::ReplaceWidthFunctions(void) { + bool replaced = false; InitIterator(); cTemplateFunction *func = NULL; while(func = GetNextFunction()) { @@ -153,14 +171,18 @@ void cTemplateLoopFunction::ReplaceWidthFunctions(void) { func->SetWidth(type, label, funcWidth); if (func->Updated()) { func->CompleteParameters(); + } else { + replaced = true; } } } } } + return replaced; } -void cTemplateLoopFunction::ReplaceHeightFunctions(void) { +bool cTemplateLoopFunction::ReplaceHeightFunctions(void) { + bool replaced = false; InitIterator(); cTemplateFunction *func = NULL; while(func = GetNextFunction()) { @@ -181,11 +203,14 @@ void cTemplateLoopFunction::ReplaceHeightFunctions(void) { func->SetHeight(type, label, funcHeight); if (func->Updated()) { func->CompleteParameters(); + } else { + replaced = true; } } } } } + return replaced; } bool cTemplateLoopFunction::Ready(void) { diff --git a/libtemplate/templateloopfunction.h b/libtemplate/templateloopfunction.h index 5335279..599dfcb 100644 --- a/libtemplate/templateloopfunction.h +++ b/libtemplate/templateloopfunction.h @@ -11,8 +11,8 @@ class cTemplateLoopFunction : public cTemplateFunction { private: vector functions; vector::iterator funcIt; - void ReplaceWidthFunctions(void); - void ReplaceHeightFunctions(void); + bool ReplaceWidthFunctions(void); + bool ReplaceHeightFunctions(void); public: cTemplateLoopFunction(void); virtual ~cTemplateLoopFunction(void);