@@ -340,10 +340,13 @@ static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, int level,
340340
341341 Vector * children = Vector_new (Class (Process ), false, DEFAULT_SIZE );
342342
343+ int lastShown = 0 ;
343344 for (int i = Vector_size (this -> processes ) - 1 ; i >= 0 ; i -- ) {
344345 Process * process = (Process * )Vector_get (this -> processes , i );
345- if (process -> show && Process_isChildOf (process , pid )) {
346+ if (Process_isChildOf (process , pid )) {
346347 process = (Process * )Vector_take (this -> processes , i );
348+ if (process -> show )
349+ lastShown = Vector_size (children );
347350 Vector_add (children , process );
348351 }
349352 }
@@ -369,8 +372,8 @@ static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, int level,
369372 assert (Vector_size (this -> processes2 ) == s + 1 ); (void )s ;
370373
371374 int nextIndent = indent | (1 << level );
372- ProcessList_buildTreeBranch (this , process -> pid , level + 1 , (i < size - 1 ) ? nextIndent : indent , direction , show ? process -> showChildren : false , node_counter , node_index );
373- if (i == size - 1 ) {
375+ ProcessList_buildTreeBranch (this , process -> pid , level + 1 , (i < lastShown ) ? nextIndent : indent , direction , process -> show && process -> showChildren , node_counter , node_index );
376+ if (i == lastShown ) {
374377 process -> indent = - nextIndent ;
375378 } else {
376379 process -> indent = nextIndent ;
@@ -418,20 +421,6 @@ static void ProcessList_buildTree(ProcessList* this) {
418421 for (i = 0 ; i < size ; i ++ ) {
419422 Process * process = (Process * )Vector_get (this -> processes , i );
420423
421- // Immediately consume processes hidden from view
422- if (!process -> show ) {
423- process = (Process * )Vector_take (this -> processes , i );
424- process -> indent = 0 ;
425- process -> tree_depth = 0 ;
426- process -> tree_left = node_counter ++ ;
427- process -> tree_index = node_index ++ ;
428- Vector_add (this -> processes2 , process );
429- ProcessList_buildTreeBranch (this , process -> pid , 0 , 0 , direction , false, & node_counter , & node_index );
430- process -> tree_right = node_counter ++ ;
431- Hashtable_put (this -> displayTreeSet , process -> tree_index , process );
432- break ;
433- }
434-
435424 pid_t ppid = Process_getParentPid (process );
436425 bool isRoot = false;
437426
0 commit comments