[ekg2-commit] ekg2: commands.c (HEAD) [peres]
CVS commit
cvs w toxygen.net
Sob, 5 Maj 2007, 11:46:12 CEST
Module name: ekg2
Changes by: peres 2007-05-05 11:46:10
Modified files:
commands.c
Log message:
Adding queries resort after plugin loading/prio change. It is kinda'
experimental thing, but should work. We're doing this by creating new, sorted
copy of the list and then replacing the original one, if no failures occured.
Thanks to that, we shouldn't break EKG2 session if something fails.
Index: commands.c
===================================================================
RCS file: /home/cvs/ekg2/ekg/commands.c,v
diff -d -u -r1.274 -r1.275
--- commands.c 5 May 2007 09:09:20 -0000 1.274
+++ commands.c 5 May 2007 09:46:09 -0000 1.275
@@ -3949,6 +3949,37 @@
}
/**
+ * resort_queries()
+ *
+ * Resorts all queries, e.g. after plugin prio change.
+ */
+void resort_queries() { /* XXX: very experimental */
+ int query_compare(query_t *a, query_t *b) {
+ /* any other suggestions: vvv ? */
+ const int ap = (a->plugin ? a->plugin->prio : -666);
+ const int bp = (b->plugin ? b->plugin->prio : -666);
+
+ return (bp-ap);
+ }
+
+ list_t tmplist = NULL;
+ list_t l;
+
+ for (l = queries; l; l = l->next) {
+ if (l->data) {
+ if (!(list_add_sorted(&tmplist, l->data, 0, query_compare))) {
+ debug_error("resort_queries(), list_add_sorted() failed, not continuing!\n");
+ list_destroy(l, 0);
+ return;
+ }
+ }
+ }
+
+ list_destroy(queries, 0);
+ queries = tmplist;
+}
+
+/**
* cmd_plugin()
*
* Manage plugins in ekg2 load/unload/list/change plugin prios<br>
@@ -3988,9 +4019,9 @@
list_remove(&plugins, p, 0);
plugin_register(p, -254);
- /* big XXX here, we don't resort queries already added by this plugin */
}
+ resort_queries();
config_changed = 1;
printq("plugin_default");
}
@@ -4002,6 +4033,7 @@
return ret;
}
+ resort_queries();
changed_theme(NULL);
return 0;
}
@@ -4019,8 +4051,8 @@
if (params[1] && (pl = plugin_find(params[0]))) {
list_remove(&plugins, pl, 0);
plugin_register(pl, atoi(params[1]));
- /* big XXX here, we don't resort queries already added by this plugin */
+ resort_queries();
config_changed = 1;
printq("plugin_prio_set", pl->name, params[1]);
Więcej informacji o liście dyskusyjnej ekg2-commit