summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 268231c)
raw | patch | inline | side by side (parent: 268231c)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 2 Jul 2006 23:26:45 +0000 (23:26 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 2 Jul 2006 23:26:45 +0000 (23:26 +0000) |
src/prefs-utils.cpp | patch | blob | history |
diff --git a/src/prefs-utils.cpp b/src/prefs-utils.cpp
index 54c83c1e9580805d1c37ab2d0f20d9bea031273f..a0851a3543693ffbe22d83c8aa653384192b29c7 100644 (file)
--- a/src/prefs-utils.cpp
+++ b/src/prefs-utils.cpp
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);
}
}
}