X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdocument-undo.cpp;h=81125833110313c50b78793bbadecf8b6ee35dde;hb=88013f5100c818a1b1c0d9d9cf773930373491cf;hp=f37b53f89c5d89c228d78dd5b9eb67c61aa3aeff;hpb=1b27a5820b3d93141c1dcc7d5eaea73e9c33ddee;p=inkscape.git diff --git a/src/document-undo.cpp b/src/document-undo.cpp index f37b53f89..811258331 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -63,6 +63,7 @@ #include "inkscape.h" #include "debug/event-tracker.h" #include "debug/simple-event.h" +#include "debug/timestamp.h" #include "event.h" @@ -129,6 +130,38 @@ sp_document_reset_key (Inkscape::Application *inkscape, SPDesktop *desktop, GtkO doc->actionkey = NULL; } +namespace { + +using Inkscape::Debug::Event; +using Inkscape::Debug::SimpleEvent; +using Inkscape::Util::share_static_string; +using Inkscape::Debug::timestamp; +using Inkscape::Verb; + +typedef SimpleEvent InteractionEvent; + +class CommitEvent : public InteractionEvent { +public: + + CommitEvent(SPDocument *doc, const gchar *key, const unsigned int type) + : InteractionEvent(share_static_string("commit")) + { + _addProperty(share_static_string("timestamp"), timestamp()); + gchar *serial = g_strdup_printf("%lu", doc->serial()); + _addProperty(share_static_string("document"), serial); + g_free(serial); + Verb *verb = Verb::get(type); + if (verb) { + _addProperty(share_static_string("context"), verb->get_id()); + } + if (key) { + _addProperty(share_static_string("merge-key"), key); + } + } +}; + +} + void sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int event_type, Glib::ustring event_description) @@ -137,6 +170,8 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev g_assert (doc->priv != NULL); g_assert (doc->priv->sensitive); + Inkscape::Debug::EventTracker tracker(doc, key, event_type); + doc->collectOrphans(); sp_document_ensure_up_to_date (doc); @@ -152,9 +187,8 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev } if (key && doc->actionkey && !strcmp (key, doc->actionkey) && doc->priv->undo) { - doc->priv->undo->data = - new Inkscape::Event(sp_repr_coalesce_log (((Inkscape::Event *) - doc->priv->undo->data)->event, log)); + ((Inkscape::Event *)doc->priv->undo->data)->event = + sp_repr_coalesce_log (((Inkscape::Event *)doc->priv->undo->data)->event, log); } else { Inkscape::Event *event = new Inkscape::Event(log, event_type, event_description); doc->priv->undo = g_slist_prepend (doc->priv->undo, event); @@ -192,9 +226,7 @@ sp_document_cancel (SPDocument *doc) sp_repr_begin_transaction (doc->rdoc); } -namespace { - -void finish_incomplete_transaction(SPDocument &doc) { +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) { @@ -208,8 +240,6 @@ void finish_incomplete_transaction(SPDocument &doc) { } } -} - gboolean sp_document_undo (SPDocument *doc) {