From 3d0e4f38019f924c773592842adad7922531e421 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 5 Aug 2011 22:39:41 +0200 Subject: [PATCH] Better fix of crash on empty game list An empty list is now replaced by a list containig a simple message. --- xgamelist.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/xgamelist.c b/xgamelist.c index e1781dc..06ebf4a 100644 --- a/xgamelist.c +++ b/xgamelist.c @@ -109,6 +109,8 @@ char gameListTranslations[] = char filterTranslations[] = "Return: SetFilterProc() \n"; +char *dummyList[] = { N_("no games matched your request"), NULL }; + typedef struct { Widget shell; Position x, y; @@ -367,7 +369,7 @@ GameListReplace() char buf[MSG_SIZ],*p; listwidg = XtNameToWidget(glc->shell, "*form.viewport.list"); - XtSetArg(arg, XtNlist, glc->strings); + XtSetArg(arg, XtNlist, listLength ? glc->strings : dummyList); // empty list displays message XawListChange(listwidg, glc->strings, 0, 0, True); XtSetValues(listwidg, &arg, 1); XawListHighlight(listwidg, 0); @@ -431,7 +433,7 @@ GameListCallback(w, client_data, call_data) XtGetValues(filterText, args, j); safeStrCpy(filterString, text, sizeof(filterString)/sizeof(filterString[0])); XawListHighlight(listwidg, 0); - if(GameListPrepare(strcmp(name, _("find position")) == 0)) GameListReplace(); // crashes on empty list... + GameListPrepare(strcmp(name, _("find position")) == 0); GameListReplace(); return; } #if 1 @@ -576,7 +578,7 @@ SetFilterProc(w, event, prms, nprms) XtSetArg(args[j], XtNstring, &name); j++; XtGetValues(filterText, args, j); safeStrCpy(filterString, name, sizeof(filterString)/sizeof(filterString[0])); - if(GameListPrepare(False)) GameListReplace(); // crashes on empty list... + GameListPrepare(False); GameListReplace(); list = XtNameToWidget(glc->shell, "*form.viewport.list"); XawListHighlight(list, 0); j = 0; -- 1.7.0.4