@@ -942,11 +942,11 @@ symbol_recalculate_sub(Symbol *sym)
942942 gboolean result = TRUE;
943943
944944#ifdef DEBUG_TIME
945- static GTimer * timer = NULL ;
945+ static GTimer * timer = NULL ;
946946
947- if (!timer )
948- timer = g_timer_new ();
949- g_timer_reset (timer );
947+ if (!timer )
948+ timer = g_timer_new ();
949+ g_timer_reset (timer );
950950#endif /*DEBUG_TIME*/
951951
952952 g_assert (is_value (sym ));
@@ -972,9 +972,9 @@ symbol_recalculate_sub(Symbol *sym)
972972 }
973973
974974#ifdef DEBUG_TIME
975- printf ("symbol_recalculate_sub: " );
976- symbol_name_scope_print (sym );
977- printf (" %g\n" , g_timer_elapsed (timer , NULL ));
975+ printf ("symbol_recalculate_sub: " );
976+ symbol_name_scope_print (sym );
977+ printf (" %g\n" , g_timer_elapsed (timer , NULL ));
978978#endif /*DEBUG_TIME*/
979979
980980 return result ;
@@ -1009,7 +1009,8 @@ symbol_get_last_calc(void)
10091009 */
10101010static gboolean symbol_running = FALSE;
10111011
1012- /* Recalc a symbol ... with error checks.
1012+ /* Recalc a symbol with error checks. This can succeed, stop with a timeout,
1013+ * or fail with an error.
10131014 */
10141015static void *
10151016symbol_recalculate_leaf_sub (Symbol * sym )
@@ -1034,6 +1035,7 @@ symbol_recalculate_leaf_sub(Symbol *sym)
10341035
10351036 return sym ;
10361037 }
1038+
10371039 if (!sym -> dirty )
10381040 return NULL ;
10391041 if (!is_value (sym )) {
@@ -1045,14 +1047,19 @@ symbol_recalculate_leaf_sub(Symbol *sym)
10451047
10461048 reduce_context -> heap -> filled = FALSE;
10471049 symbol_running = TRUE;
1048- progress_begin ();
10491050 symbol_note_calc_name (sym );
1050- if (!symbol_recalculate_sub (sym ) ||
1051+ progress_begin ();
1052+
1053+ // false for error, true for success or timeout
1054+ gboolean result = symbol_recalculate_sub (sym );
1055+
1056+ symbol_running = FALSE;
1057+ progress_end ();
1058+
1059+ if (!result ||
10511060 reduce_context -> heap -> filled ) {
10521061 if (sym -> expr )
10531062 expr_error_set (sym -> expr );
1054- symbol_running = FALSE;
1055- progress_end ();
10561063
10571064#ifdef DEBUG_RECALC
10581065 if (sym -> expr )
@@ -1063,11 +1070,9 @@ symbol_recalculate_leaf_sub(Symbol *sym)
10631070
10641071 return sym ;
10651072 }
1066- symbol_running = FALSE;
1067- progress_end ();
10681073
1069- /* Have we discovered any dirty children? If not, we've cleaned this
1070- * sym .
1074+ /* Any dirty children? If not, we've cleaned this sym and it can come
1075+ * off the leaf set .
10711076 */
10721077 if (!sym -> ndirtychildren ) {
10731078 symbol_dirty_clear (sym );
@@ -1124,11 +1129,11 @@ symbol_recalculate_leaf(void)
11241129 /* We can get errors during backtracking, don't report here.
11251130 */
11261131
1127- /* Note a pending GC.
1132+ /* Queue a GC.
11281133 */
11291134 (void ) heap_gc_request (reduce_context -> heap );
11301135
1131- /* We have recalculated a symbol .
1136+ /* We have made some progress .
11321137 */
11331138 recalculated = TRUE;
11341139 }
@@ -1143,10 +1148,6 @@ static gint symbol_idle_id = 0;
11431148static gboolean
11441149symbol_recalculate_idle (void * user_data )
11451150{
1146- static GTimer * timer = NULL ;
1147-
1148- gboolean run_again ;
1149-
11501151#ifdef DEBUG_RECALC
11511152 printf ("symbol_recalculate_idle:\n" );
11521153#endif /*DEBUG_RECALC*/
@@ -1158,34 +1159,22 @@ symbol_recalculate_idle(void *user_data)
11581159 */
11591160 return TRUE;
11601161
1161- if (!timer )
1162- timer = g_timer_new ();
1163-
1164- g_timer_reset (timer );
1165-
1166- run_again = TRUE;
1167-
1168- if (!mainwindow_auto_recalc )
1169- /* Auto-calc has been turned off during a recomp.
1170- */
1171- run_again = FALSE;
1172- else
1173- while (g_timer_elapsed (timer , NULL ) < 0.1 )
1174- if (!symbol_recalculate_leaf ()) {
1175- run_again = FALSE;
1176- break ;
1177- }
1162+ if (mainwindow_auto_recalc )
1163+ while (symbol_recalculate_leaf ())
1164+ ;
11781165
1179- if (!run_again ) {
1166+ if (!symbol_leaf_next () ) {
11801167#ifdef DEBUG_RECALC
11811168 printf ("symbol_recalculate_idle: bg recalc done\n" );
11821169#endif /*DEBUG_RECALC*/
11831170
11841171 symbol_idle_id = 0 ;
11851172 progress_end ();
1186- }
11871173
1188- return run_again ;
1174+ return FALSE;
1175+ }
1176+ else
1177+ return TRUE;
11891178}
11901179
11911180/* Recalculate ... either nudge the idle recomp, or in batch mode, do a recomp
0 commit comments