diff --git a/src/document-undo.cpp b/src/document-undo.cpp
index 9dbf5db25b915b127987f2c640ef3e81ab74106f..e63fe8a529c552e19f12a82419d4ef6a1635f8f1 100644 (file)
--- a/src/document-undo.cpp
+++ b/src/document-undo.cpp
* stack. Two methods exist to indicate that the given action is completed:
*
* \verbatim
- void sp_document_done (Document *document);
- void sp_document_maybe_done (Document *document, const unsigned char *key) \endverbatim
+ void sp_document_done (SPDocument *document);
+ void sp_document_maybe_done (SPDocument *document, const unsigned char *key) \endverbatim
*
* Both move the recent action list into the undo stack and clear the
* list afterwards. While the first method does an unconditional push,
sp_document_set_undo_sensitive(document, saved); \endverbatim
*/
void
-sp_document_set_undo_sensitive (Document *doc, bool sensitive)
+sp_document_set_undo_sensitive (SPDocument *doc, bool sensitive)
{
g_assert (doc != NULL);
g_assert (doc->priv != NULL);
* the saved bools in a stack. Perhaps this is why the above solution is better.
*/
-bool sp_document_get_undo_sensitive(Document const *document) {
+bool sp_document_get_undo_sensitive(SPDocument const *document) {
g_assert(document != NULL);
g_assert(document->priv != NULL);
}
void
-sp_document_done (Document *doc, const unsigned int event_type, Glib::ustring event_description)
+sp_document_done (SPDocument *doc, const unsigned int event_type, Glib::ustring event_description)
{
sp_document_maybe_done (doc, NULL, event_type, event_description);
}
-void
-sp_document_reset_key (Inkscape::Application */*inkscape*/, SPDesktop */*desktop*/, GtkObject *base)
+void sp_document_reset_key( Inkscape::Application * /*inkscape*/, SPDesktop * /*desktop*/, GtkObject *base )
{
- Document *doc = (Document *) base;
- doc->actionkey = NULL;
+ SPDocument *doc = reinterpret_cast<SPDocument *>(base);
+ doc->actionkey.clear();
}
namespace {
class CommitEvent : public InteractionEvent {
public:
- CommitEvent(Document *doc, const gchar *key, const unsigned int type)
+ CommitEvent(SPDocument *doc, const gchar *key, const unsigned int type)
: InteractionEvent(share_static_string("commit"))
{
_addProperty(share_static_string("timestamp"), timestamp());
}
void
-sp_document_maybe_done (Document *doc, const gchar *key, const unsigned int event_type,
+sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int event_type,
Glib::ustring event_description)
{
g_assert (doc != NULL);
g_assert (doc->priv != NULL);
g_assert (doc->priv->sensitive);
+ if ( key && !*key ) {
+ g_warning("Blank undo key specified.");
+ }
Inkscape::Debug::EventTracker<CommitEvent> tracker(doc, key, event_type);
@@ -188,7 +190,7 @@ sp_document_maybe_done (Document *doc, const gchar *key, const unsigned int even
return;
}
- if (key && doc->actionkey && !strcmp (key, doc->actionkey) && doc->priv->undo) {
+ if (key && !doc->actionkey.empty() && (doc->actionkey == key) && doc->priv->undo) {
((Inkscape::Event *)doc->priv->undo->data)->event =
sp_repr_coalesce_log (((Inkscape::Event *)doc->priv->undo->data)->event, log);
} else {
@@ -198,7 +200,11 @@ sp_document_maybe_done (Document *doc, const gchar *key, const unsigned int even
doc->priv->undoStackObservers.notifyUndoCommitEvent(event);
}
- doc->actionkey = key;
+ if ( key ) {
+ doc->actionkey = key;
+ } else {
+ doc->actionkey.clear();
+ }
doc->virgin = FALSE;
doc->setModifiedSinceSave();
@@ -209,7 +215,7 @@ sp_document_maybe_done (Document *doc, const gchar *key, const unsigned int even
}
void
-sp_document_cancel (Document *doc)
+sp_document_cancel (SPDocument *doc)
{
g_assert (doc != NULL);
g_assert (doc->priv != NULL);
sp_repr_begin_transaction (doc->rdoc);
}
-static void finish_incomplete_transaction(Document &doc) {
- DocumentPrivate &priv=*doc.priv;
+static void finish_incomplete_transaction(SPDocument &doc) {
+ SPDocumentPrivate &priv=*doc.priv;
Inkscape::XML::Event *log=sp_repr_commit_undoable(doc.rdoc);
if (log || priv.partial) {
g_warning ("Incomplete undo transaction:");
}
gboolean
-sp_document_undo (Document *doc)
+sp_document_undo (SPDocument *doc)
{
using Inkscape::Debug::EventTracker;
using Inkscape::Debug::SimpleEvent;
doc->priv->sensitive = FALSE;
doc->priv->seeking = true;
- doc->actionkey = NULL;
+ doc->actionkey.clear();
finish_incomplete_transaction(*doc);
}
gboolean
-sp_document_redo (Document *doc)
+sp_document_redo (SPDocument *doc)
{
using Inkscape::Debug::EventTracker;
using Inkscape::Debug::SimpleEvent;
doc->priv->sensitive = FALSE;
doc->priv->seeking = true;
- doc->actionkey = NULL;
+ doc->actionkey.clear();
finish_incomplete_transaction(*doc);
}
void
-sp_document_clear_undo (Document *doc)
+sp_document_clear_undo (SPDocument *doc)
{
if (doc->priv->undo)
doc->priv->undoStackObservers.notifyClearUndoEvent();
}
void
-sp_document_clear_redo (Document *doc)
+sp_document_clear_redo (SPDocument *doc)
{
if (doc->priv->redo)
doc->priv->undoStackObservers.notifyClearRedoEvent();