Browse Source

Added workaround for the crash described in https://gitlab.gnome.org/GNOME/gtk/-/issues/5593

merge-requests/413/head
eidheim 3 years ago
parent
commit
c43b5fff96
  1. 8
      src/selection_dialog.cpp
  2. 2
      src/selection_dialog.hpp
  3. 7
      src/tooltips.cpp
  4. 2
      tests/stubs/selection_dialog.cpp

8
src/selection_dialog.cpp

@ -137,6 +137,14 @@ SelectionDialogBase::SelectionDialogBase(Source::BaseView *view_, const boost::o
}); });
} }
SelectionDialogBase::~SelectionDialogBase() {
#if defined(__APPLE__) && GTK_VERSION_GT_MICRO(3, 24, 34)
// Workaround for https://gitlab.gnome.org/GNOME/gtk/-/issues/5593 by keeping window alive slightly longer
window.close();
Glib::signal_timeout().connect([window = std::make_shared<Gtk::Window>(std::move(window))] { return false; }, 5000);
#endif
}
void SelectionDialogBase::cursor_changed() { void SelectionDialogBase::cursor_changed() {
if(!is_visible()) if(!is_visible())
return; return;

2
src/selection_dialog.hpp

@ -39,7 +39,7 @@ class SelectionDialogBase {
public: public:
SelectionDialogBase(Source::BaseView *view, const boost::optional<Gtk::TextIter> &start_iter, bool show_search_entry, bool use_markup); SelectionDialogBase(Source::BaseView *view, const boost::optional<Gtk::TextIter> &start_iter, bool show_search_entry, bool use_markup);
virtual ~SelectionDialogBase() {} virtual ~SelectionDialogBase();
void add_row(const std::string &row); void add_row(const std::string &row);
void erase_rows(); void erase_rows();
void set_cursor_at_last_row(); void set_cursor_at_last_row();

7
src/tooltips.cpp

@ -19,6 +19,13 @@ Tooltip::Tooltip(std::function<void(Tooltip &)> set_buffer_)
: view(nullptr), set_buffer(std::move(set_buffer_)) {} : view(nullptr), set_buffer(std::move(set_buffer_)) {}
Tooltip::~Tooltip() { Tooltip::~Tooltip() {
#if defined(__APPLE__) && GTK_VERSION_GT_MICRO(3, 24, 34)
// Workaround for https://gitlab.gnome.org/GNOME/gtk/-/issues/5593 by keeping window alive slightly longer
if(window) {
window->close();
Glib::signal_timeout().connect([window = std::shared_ptr<Gtk::Window>(std::move(window))] { return false; }, 5000);
}
#endif
Tooltips::shown_tooltips.erase(this); Tooltips::shown_tooltips.erase(this);
} }

2
tests/stubs/selection_dialog.cpp

@ -5,6 +5,8 @@ SelectionDialogBase::ListViewText::ListViewText(bool use_markup) {}
SelectionDialogBase::SelectionDialogBase(Source::BaseView *view, const boost::optional<Gtk::TextIter> &start_iter, bool show_search_entry, bool use_markup) SelectionDialogBase::SelectionDialogBase(Source::BaseView *view, const boost::optional<Gtk::TextIter> &start_iter, bool show_search_entry, bool use_markup)
: view(view), list_view_text(use_markup) {} : view(view), list_view_text(use_markup) {}
SelectionDialogBase::~SelectionDialogBase() {}
void SelectionDialogBase::show() {} void SelectionDialogBase::show() {}
void SelectionDialogBase::hide() {} void SelectionDialogBase::hide() {}

Loading…
Cancel
Save