GUI_App: Remove custom CallAfter
This commit is contained in:
parent
b3d7bf1c1e
commit
984b1bc1c1
2 changed files with 0 additions and 35 deletions
|
@ -164,27 +164,8 @@ bool GUI_App::OnInit()
|
||||||
// to correct later layouts
|
// to correct later layouts
|
||||||
});
|
});
|
||||||
|
|
||||||
// This makes CallAfter() work
|
|
||||||
Bind(wxEVT_IDLE, [this](wxIdleEvent& event)
|
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())
|
if (app_config->dirty())
|
||||||
app_config->save();
|
app_config->save();
|
||||||
|
|
||||||
|
@ -420,16 +401,6 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files)
|
||||||
dialog.GetPaths(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
|
// select language from the list of installed languages
|
||||||
bool GUI_App::select_language( wxArrayString & names,
|
bool GUI_App::select_language( wxArrayString & names,
|
||||||
wxArrayLong & identifiers)
|
wxArrayLong & identifiers)
|
||||||
|
|
|
@ -73,11 +73,6 @@ class GUI_App : public wxApp
|
||||||
{
|
{
|
||||||
bool app_conf_exists{ false };
|
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_modified;
|
||||||
wxColour m_color_label_sys;
|
wxColour m_color_label_sys;
|
||||||
wxColour m_color_label_default;
|
wxColour m_color_label_default;
|
||||||
|
@ -124,7 +119,6 @@ public:
|
||||||
|
|
||||||
void persist_window_geometry(wxTopLevelWindow *window);
|
void persist_window_geometry(wxTopLevelWindow *window);
|
||||||
void update_ui_from_settings();
|
void update_ui_from_settings();
|
||||||
void CallAfter(std::function<void()> cb);
|
|
||||||
|
|
||||||
bool select_language(wxArrayString & names, wxArrayLong & identifiers);
|
bool select_language(wxArrayString & names, wxArrayLong & identifiers);
|
||||||
bool load_language();
|
bool load_language();
|
||||||
|
|
Loading…
Reference in a new issue