Skip to content

Commit

Permalink
Fix view switching calls order.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jan 24, 2023
1 parent 6b4be88 commit 7579471
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions app.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,33 @@ static void app_switch_view(ProtoViewApp *app, ProtoViewCurrentView switchto) {
}
ProtoViewCurrentView new = app->current_view;

/* Set the current subview of the view we just left to zero. This is
* the main subview of the old view. When re re-enter the view we are
* lefting, we want to see the main thing again. */
app->current_subview[old] = 0;

/* Reset the view private data each time, before calling the enter/exit
* callbacks that may want to setup some state. */
memset(app->view_privdata,0,PROTOVIEW_VIEW_PRIVDATA_LEN);

/* Call the enter/exit view callbacks if needed. */
/* Call the exit view callbacks. */
if (old == ViewDirectSampling) view_exit_direct_sampling(app);
if (new == ViewDirectSampling) view_enter_direct_sampling(app);
if (old == ViewBuildMessage) view_exit_build_message(app);
if (new == ViewBuildMessage) view_enter_build_message(app);
if (old == ViewInfo) view_exit_info(app);

/* The frequency/modulation settings are actually a single view:
* as long as the user stays between the two modes of this view we
* don't need to call the exit-view callback. */
if ((old == ViewFrequencySettings && new != ViewModulationSettings) ||
(old == ViewModulationSettings && new != ViewFrequencySettings))
view_exit_settings(app);

/* Reset the view private data each time, before calling the enter
* callbacks that may want to setup some state. */
memset(app->view_privdata,0,PROTOVIEW_VIEW_PRIVDATA_LEN);

/* Call the enter view callbacks after all the exit callback
* of the old view was already executed. */
if (new == ViewDirectSampling) view_enter_direct_sampling(app);
if (new == ViewBuildMessage) view_enter_build_message(app);

/* Set the current subview of the view we just left to zero. This is
* the main subview of the old view. When we re-enter the view we are
* lefting, we want to see the main thing again. */
app->current_subview[old] = 0;

/* If there is an alert on screen, dismiss it: if the user is
* switching view she already read it. */
ui_dismiss_alert(app);
}

Expand Down

0 comments on commit 7579471

Please sign in to comment.