MCPcopy Create free account
hub / github.com/ashaduri/gsmartcontrol / execute_tick_func

Method execute_tick_func

src/applib/command_executor_gui.cpp:148–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146
147
148bool CommandExecutorGui::execute_tick_func(TickStatus status)
149{
150 if (status == TickStatus::Starting) {
151 if (execution_running_)
152 return false; // already running, abort the new one (?)
153
154 // If quit() was called during one of the manual iterations, and execute()
155 // is called in a loop, we need to prevent any real execution past that point.
156 if (Gtk::Main::iteration(false) && Gtk::Main::level() > 0) {
157 return false; // try to abort execution
158 }
159
160 execution_running_ = true;
161 should_abort_ = false;
162
163 // show a dialog with "running..." and an Abort button
164 this->show_hide_dialog(true);
165
166 return true; // proceed with execution
167 }
168
169
170 if (status == TickStatus::Failed) {
171
172 // close the dialog
173 this->show_hide_dialog(false);
174
175 // show a dialog with an error.
176 // Handled by sync_errors_warn(), nothing else is needed here.
177
178 execution_running_ = false;
179 return true; // return value is ignored here
180 }
181
182
183 if (status == TickStatus::Running) {
184
185 while (Gtk::Main::events_pending()) {
186 // Gtk::Main::iteration() returns true if Gtk::Main::quit() has been called, or if there's no Main yet.
187 // debug_out_dump("app", Gtk::Main::level() << "\n");
188 if (Gtk::Main::iteration() && Gtk::Main::level() > 0) {
189 set_running_dialog_abort_mode(true);
190 return false; // try to abort execution
191 }
192 }
193
194 if (should_abort_) {
195 should_abort_ = false;
196 set_running_dialog_abort_mode(true);
197 return false; // try to abort execution
198 }
199
200 // the dialog may be shown only after some time has passed, to avoid quick show/hide.
201 // this enables it.
202 this->update_dialog_show_timer();
203
204 return true; // continue execution
205 }

Callers

nothing calls this directly

Calls 2

show_hide_dialogMethod · 0.95

Tested by

no test coverage detected