From e96322b3511418ad3fd64a4cd92be3cb3a7a61f8 Mon Sep 17 00:00:00 2001 From: mfranz Date: Sun, 11 Jan 2009 02:42:33 +0000 Subject: [PATCH] OverlaySelector: don't choke if there are no options --- Nasal/gui.nas | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Nasal/gui.nas b/Nasal/gui.nas index 046bcec12..1488b6ee6 100644 --- a/Nasal/gui.nas +++ b/Nasal/gui.nas @@ -352,18 +352,21 @@ var OverlaySelector = { }, rescan: func { me.data = []; - foreach (var file; directory(me.dir)) { - if (substr(file, -4) != ".xml") - continue; - var n = io.read_properties(me.dir ~ file); - var name = n.getNode(me.nameprop, 1).getValue(); - var index = n.getNode(me.sortprop, 1).getValue(); - if (name == nil or index == nil) - continue; - append(me.data, [name, index, substr(file, 0, size(file) - 4), me.dir ~ file]); + var files = directory(me.dir); + if (size(files)) { + foreach (var file; files) { + if (substr(file, -4) != ".xml") + continue; + var n = io.read_properties(me.dir ~ file); + var name = n.getNode(me.nameprop, 1).getValue(); + var index = n.getNode(me.sortprop, 1).getValue(); + if (name == nil or index == nil) + continue; + append(me.data, [name, index, substr(file, 0, size(file) - 4), me.dir ~ file]); + } + me.data = sort(me.data, func(a, b) num(a[1]) == nil or num(b[1]) == nil + ? cmp(a[1], b[1]) : a[1] - b[1]); } - me.data = sort(me.data, func(a, b) num(a[1]) == nil or num(b[1]) == nil - ? cmp(a[1], b[1]) : a[1] - b[1]); me.list.removeChildren("value"); forindex (var i; me.data)