Skip to content

Commit

Permalink
undo_history: fix move between documents
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwhite committed Nov 5, 2024
1 parent 6f27cc9 commit 43d21a4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
22 changes: 0 additions & 22 deletions src/ui/dialog/undo-history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,42 +103,20 @@ void UndoHistory::disconnectEventLog()
{
if (_event_log) {
_event_log->removeDialogConnection(&_event_list_view, &_callback_connections);
_event_log->remove_destroy_notify_callback(this);
}
}

void UndoHistory::connectEventLog()
{
if (auto document = getDocument()) {
_event_log = document->get_event_log();
_event_log->add_destroy_notify_callback(this, &_handleEventLogDestroyCB);
_event_list_store = _event_log->getEventListStore();
_event_list_view.set_model(_event_list_store);
_event_log->addDialogConnection(&_event_list_view, &_callback_connections);
_event_list_view.scroll_to_row(_event_list_store->get_path(_event_list_selection->get_selected()));
}
}

void UndoHistory::_handleEventLogDestroyCB(sigc::notifiable * const data)
{
if (data) {
UndoHistory *self = reinterpret_cast<UndoHistory*>(data);
self->_handleEventLogDestroy();
}
}

// called *after* _event_log has been destroyed.
void UndoHistory::_handleEventLogDestroy()
{
if (_event_log) {
auto blocker = SignalBlocker{_callback_connections[EventLog::CALLB_SELECTION_CHANGE]};

_event_list_view.unset_model();
_event_list_store.reset();
_event_log = nullptr;
}
}

void
UndoHistory::_onListSelectionChange()
{
Expand Down
3 changes: 0 additions & 3 deletions src/ui/dialog/undo-history.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,9 @@ class UndoHistory : public DialogBase

EventLog::CallbackMap _callback_connections;

static void _handleEventLogDestroyCB(sigc::notifiable *data);

void disconnectEventLog();
void connectEventLog();

void _handleEventLogDestroy();
void _onListSelectionChange();
void _onExpandEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path);
void _onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path);
Expand Down

0 comments on commit 43d21a4

Please sign in to comment.