From c6caaf4a1732f82614f59f53ce3ed2c67d44e903 Mon Sep 17 00:00:00 2001 From: alle Date: Thu, 13 May 2010 08:36:38 +0000 Subject: [PATCH] Correct detection of the absence of the current preset git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25990 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_tokens.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 165c3b9b4..b9d4bd6b1 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -398,13 +398,15 @@ const char *get_radio_token(struct wps_token *token, int preset_offset, case WPS_TOKEN_PRESET_NAME: case WPS_TOKEN_PRESET_FREQ: { - int preset = radio_current_preset() + preset_offset; - if (radio_preset_count() == 0 || preset == -1) + int preset_count = radio_preset_count(); + int cur_preset = radio_current_preset(); + if (preset_count == 0 || cur_preset < 0) return NULL; - /* make sure its in the valid range */ + int preset = cur_preset + preset_offset; + /* make sure it's in the valid range */ while (preset < 0) - preset += radio_preset_count(); - preset %= radio_preset_count(); + preset += preset_count; + preset %= preset_count; if (token->type == WPS_TOKEN_PRESET_NAME) { snprintf(buf, buf_size, "%s", radio_get_preset(preset)->name); -- 2.11.4.GIT