GUI_App: Remove custom CallAfter

This commit is contained in:
Vojtech Kral 2019-01-17 17:41:07 +01:00
parent b3d7bf1c1e
commit 984b1bc1c1
2 changed files with 0 additions and 35 deletions

View file

@ -164,27 +164,8 @@ bool GUI_App::OnInit()
// to correct later layouts
});
// This makes CallAfter() work
Bind(wxEVT_IDLE, [this](wxIdleEvent& event)
{
std::function<void()> cur_cb{ nullptr };
// try to get the mutex. If we can't, just skip this idle event and get the next one.
if (!callback_register.try_lock()) return;
// pop callback
if (m_cb.size() != 0) {
cur_cb = m_cb.top();
m_cb.pop();
}
// unlock mutex
this->callback_register.unlock();
try { // call the function if it's not nullptr;
if (cur_cb != nullptr) cur_cb();
}
catch (std::exception& e) {
std::cerr << "Exception thrown: " << e.what() << std::endl;
}
if (app_config->dirty())
app_config->save();
@ -420,16 +401,6 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files)
dialog.GetPaths(input_files);
}
void GUI_App::CallAfter(std::function<void()> cb)
{
// set mutex
callback_register.lock();
// push function onto stack
m_cb.emplace(cb);
// unset mutex
callback_register.unlock();
}
// select language from the list of installed languages
bool GUI_App::select_language( wxArrayString & names,
wxArrayLong & identifiers)

View file

@ -73,11 +73,6 @@ class GUI_App : public wxApp
{
bool app_conf_exists{ false };
// Lock to guard the callback stack
std::mutex callback_register;
// callbacks registered to run during idle event.
std::stack<std::function<void()>> m_cb{};
wxColour m_color_label_modified;
wxColour m_color_label_sys;
wxColour m_color_label_default;
@ -124,7 +119,6 @@ public:
void persist_window_geometry(wxTopLevelWindow *window);
void update_ui_from_settings();
void CallAfter(std::function<void()> cb);
bool select_language(wxArrayString & names, wxArrayLong & identifiers);
bool load_language();