Skip to content

Commit

Permalink
TraversableNodeSet migrated to use UndoSystem signals
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 1, 2017
1 parent f573082 commit b1953ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
15 changes: 7 additions & 8 deletions libs/scene/TraversableNodeSet.cpp
Expand Up @@ -263,20 +263,19 @@ void TraversableNodeSet::importState(const IUndoMementoPtr& state)
if (!_undoInsertBuffer.empty())
{
// Register to get notified when the undo operation is complete
GlobalUndoSystem().addObserver(this);
_undoHandler = GlobalUndoSystem().signal_postUndo().connect(
sigc::mem_fun(this, &TraversableNodeSet::onUndoRedoOperationFinished));
_redoHandler = GlobalUndoSystem().signal_postRedo().connect(
sigc::mem_fun(this, &TraversableNodeSet::onUndoRedoOperationFinished));
}
}

void TraversableNodeSet::postUndo()
void TraversableNodeSet::onUndoRedoOperationFinished()
{
processInsertBuffer();
GlobalUndoSystem().removeObserver(this);
}
_undoHandler.disconnect();
_redoHandler.disconnect();

void TraversableNodeSet::postRedo()
{
processInsertBuffer();
GlobalUndoSystem().removeObserver(this);
}

void TraversableNodeSet::processInsertBuffer()
Expand Down
14 changes: 9 additions & 5 deletions libs/scene/TraversableNodeSet.h
Expand Up @@ -4,6 +4,8 @@
#include "iundo.h"
#include <list>
#include <boost/noncopyable.hpp>
#include <sigc++/connection.h>
#include <sigc++/trackable.h>

class IMapFileChangeTracker;

Expand All @@ -24,7 +26,7 @@ class Node;
class TraversableNodeSet :
public IUndoable,
public boost::noncopyable,
public UndoSystem::Observer
public sigc::trackable
{
public:
typedef std::list<INodePtr> NodeList;
Expand All @@ -40,6 +42,9 @@ class TraversableNodeSet :
// A list collecting nodes for insertion in postUndo/postRedo
NodeList _undoInsertBuffer;

sigc::connection _undoHandler;
sigc::connection _redoHandler;

public:
// Default constructor, creates an empty set
TraversableNodeSet(Node& owner);
Expand Down Expand Up @@ -91,13 +96,12 @@ class TraversableNodeSet :
IUndoMementoPtr exportState() const;
void importState(const IUndoMementoPtr& state);

// UndoSystem::Observer implementation
void postUndo();
void postRedo();

void setRenderSystem(const RenderSystemPtr& renderSystem);

private:
// UndoSystem event handler
void onUndoRedoOperationFinished();

// Sends the current state to the undosystem
void undoSave();

Expand Down

0 comments on commit b1953ec

Please sign in to comment.