mirror of https://github.com/xzeldon/htop.git
Fix issue with inconsistent displayTreeSet
This commit is contained in:
parent
cf306ff86e
commit
4907d90cff
|
@ -241,6 +241,10 @@ static void ProcessList_updateTreeSetLayer(ProcessList* this, unsigned int leftB
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable_put(this->draftingTreeSet, proc->tree_index, proc);
|
Hashtable_put(this->draftingTreeSet, proc->tree_index, proc);
|
||||||
|
|
||||||
|
// It's not strictly necessary to do this, but doing so anyways
|
||||||
|
// allows for checking the correctness of the inner workings.
|
||||||
|
Hashtable_remove(this->displayTreeSet, newLeftBound);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector_delete(layer);
|
Vector_delete(layer);
|
||||||
|
@ -249,15 +253,20 @@ static void ProcessList_updateTreeSetLayer(ProcessList* this, unsigned int leftB
|
||||||
static void ProcessList_updateTreeSet(ProcessList* this) {
|
static void ProcessList_updateTreeSet(ProcessList* this) {
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
unsigned int tree_index = 1;
|
unsigned int tree_index = 1;
|
||||||
int vsize = Vector_size(this->processes);
|
|
||||||
|
const int vsize = Vector_size(this->processes);
|
||||||
|
|
||||||
|
assert(Hashtable_count(this->draftingTreeSet) == 0);
|
||||||
|
assert((int)Hashtable_count(this->displayTreeSet) == vsize);
|
||||||
|
|
||||||
ProcessList_updateTreeSetLayer(this, 0, vsize, 0, 0, vsize * 2 + 1, &index, &tree_index, -1);
|
ProcessList_updateTreeSetLayer(this, 0, vsize, 0, 0, vsize * 2 + 1, &index, &tree_index, -1);
|
||||||
assert((int)Hashtable_count(this->draftingTreeSet) == vsize);
|
|
||||||
|
|
||||||
for(int i = 0; i < vsize; i++) {
|
Hashtable* tmp = this->draftingTreeSet;
|
||||||
Process* proc = (Process*)Hashtable_remove(this->draftingTreeSet, i);
|
this->draftingTreeSet = this->displayTreeSet;
|
||||||
Hashtable_put(this->displayTreeSet, i, proc);
|
this->displayTreeSet = tmp;
|
||||||
}
|
|
||||||
|
assert(Hashtable_count(this->draftingTreeSet) == 0);
|
||||||
|
assert((int)Hashtable_count(this->displayTreeSet) == vsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, int level, int indent, int direction, bool show, int* node_counter, int* node_index) {
|
static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, int level, int indent, int direction, bool show, int* node_counter, int* node_index) {
|
||||||
|
@ -530,5 +539,11 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear out the hashtable to avoid any left-over processes from previous build
|
||||||
|
//
|
||||||
|
// The sorting algorithm relies on the fact that
|
||||||
|
// len(this->displayTreeSet) == len(this->processes)
|
||||||
|
Hashtable_clear(this->displayTreeSet);
|
||||||
|
|
||||||
ProcessList_buildTree(this);
|
ProcessList_buildTree(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue