From 6dcd3754e15a19058af2e16e179b1adf8d9d3ecf Mon Sep 17 00:00:00 2001 From: buliabyak Date: Sun, 2 Jul 2006 23:26:45 +0000 Subject: [PATCH] patch for bug 1515934 --- src/prefs-utils.cpp | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/prefs-utils.cpp b/src/prefs-utils.cpp index 54c83c1e9..a0851a354 100644 --- a/src/prefs-utils.cpp +++ b/src/prefs-utils.cpp @@ -123,26 +123,32 @@ prefs_set_recent_file(gchar const *uri, gchar const *name) if (uri != NULL) { Inkscape::XML::Node *recent = inkscape_get_repr(INKSCAPE, "documents.recent"); if (recent) { - Inkscape::XML::Node *child = sp_repr_lookup_child(recent, "uri", uri); - if (child) { - recent->changeOrder(child, NULL); - } else { - if (recent->childCount() >= max_documents) { - child = recent->firstChild(); - // count to the last - for (unsigned i = 0; i + 2 < max_documents; ++i) { - child = child->next(); - } - // remove all after the last - while (child->next()) { - sp_repr_unparent(child->next()); - } + // remove excess recent files + if (recent->childCount() >= max_documents) { + Inkscape::XML::Node *child = recent->firstChild(); + // count to the last + for (unsigned i = 0; child && i + 1 < max_documents; ++i) { + child = child->next(); } - child = sp_repr_new("document"); - child->setAttribute("uri", uri); - recent->addChild(child, NULL); + // remove all after the last + while (child) { + Inkscape::XML::Node *next = child->next(); + sp_repr_unparent(child); + child = next; + } + } + + if (max_documents > 0) { + Inkscape::XML::Node *child = sp_repr_lookup_child(recent, "uri", uri); + if (child) { + recent->changeOrder(child, NULL); + } else { + child = sp_repr_new("document"); + child->setAttribute("uri", uri); + recent->addChild(child, NULL); + } + child->setAttribute("name", name); } - child->setAttribute("name", name); } } } -- 2.30.2