@@ -67,8 +67,9 @@ impl TimePanel {
67
67
time_panel_expanded : bool ,
68
68
) {
69
69
// Naturally, many parts of the time panel need the time control.
70
- // Copy it once, read/edit, and then write back at the end.
71
- let mut time_ctrl = ctx. rec_cfg . time_ctrl . read ( ) . clone ( ) ;
70
+ // Copy it once, read/edit, and then write back at the end if there was a change.
71
+ let time_ctrl_before = ctx. rec_cfg . time_ctrl . read ( ) . clone ( ) ;
72
+ let mut time_ctrl_after = time_ctrl_before. clone ( ) ;
72
73
73
74
// this is the size of everything above the central panel (window title bar, top bar on web,
74
75
// etc.)
@@ -115,7 +116,7 @@ impl TimePanel {
115
116
ui. horizontal ( |ui| {
116
117
ui. spacing_mut ( ) . interact_size = Vec2 :: splat ( top_bar_height) ;
117
118
ui. visuals_mut ( ) . button_frame = true ;
118
- self . collapsed_ui ( ctx, ui, & mut time_ctrl ) ;
119
+ self . collapsed_ui ( ctx, ui, & mut time_ctrl_after ) ;
119
120
} ) ;
120
121
} else {
121
122
// Expanded:
@@ -129,7 +130,7 @@ impl TimePanel {
129
130
ui. horizontal ( |ui| {
130
131
ui. spacing_mut ( ) . interact_size = Vec2 :: splat ( top_bar_height) ;
131
132
ui. visuals_mut ( ) . button_frame = true ;
132
- self . top_row_ui ( ctx, ui, & mut time_ctrl ) ;
133
+ self . top_row_ui ( ctx, ui, & mut time_ctrl_after ) ;
133
134
} ) ;
134
135
} )
135
136
. response
@@ -148,15 +149,20 @@ impl TimePanel {
148
149
let mut streams_frame = egui:: Frame :: default ( ) ;
149
150
streams_frame. inner_margin . left = margin. x ;
150
151
streams_frame. show ( ui, |ui| {
151
- self . expanded_ui ( ctx, ui, & mut time_ctrl ) ;
152
+ self . expanded_ui ( ctx, ui, & mut time_ctrl_after ) ;
152
153
} ) ;
153
154
} ) ;
154
155
}
155
156
} ,
156
157
) ;
157
158
158
- // Apply potential changes of the time control:
159
- * ctx. rec_cfg . time_ctrl . write ( ) = time_ctrl;
159
+ // Apply time control if there were any changes.
160
+ // This means that if anyone else meanwhile changed the time control, these changes are lost now.
161
+ // At least though we don't overwrite them if we didn't change anything at all.
162
+ // Since changes on the time control via the time panel are rare, this should be fine.
163
+ if time_ctrl_before != time_ctrl_after {
164
+ * ctx. rec_cfg . time_ctrl . write ( ) = time_ctrl_after;
165
+ }
160
166
}
161
167
162
168
#[ allow( clippy:: unused_self) ]
0 commit comments