@@ -79,7 +79,9 @@ ops.OdtDocument = function OdtDocument(odfCanvas) {
7979 /**@const */ SHOW_ALL = NodeFilter . SHOW_ALL ,
8080 blacklistedNodes = new gui . BlacklistNamespaceNodeFilter ( [ "urn:webodf:names:cursor" , "urn:webodf:names:editinfo" ] ) ,
8181 odfTextBodyFilter = new gui . OdfTextBodyNodeFilter ( ) ,
82- defaultNodeFilter = new core . NodeFilterChain ( [ blacklistedNodes , odfTextBodyFilter ] ) ;
82+ defaultNodeFilter = new core . NodeFilterChain ( [ blacklistedNodes , odfTextBodyFilter ] ) ,
83+ /**@type {!Array.<!function():undefined> }*/
84+ pendingSignals = [ ] ;
8385
8486 /**
8587 *
@@ -890,12 +892,18 @@ ops.OdtDocument = function OdtDocument(odfCanvas) {
890892 } ;
891893
892894 /**
895+ * Emit a signal to interested subscribers. Note, signals are not emitted
896+ * until *after* the current operation has completed execution in order to
897+ * ensure operation atomicity.
898+ *
893899 * @param {!string } eventid
894900 * @param {* } args
895901 * @return {undefined }
896902 */
897903 this . emit = function ( eventid , args ) {
898- eventNotifier . emit ( eventid , args ) ;
904+ pendingSignals . push ( function ( ) {
905+ eventNotifier . emit ( eventid , args ) ;
906+ } ) ;
899907 } ;
900908
901909 /**
@@ -963,6 +971,18 @@ ops.OdtDocument = function OdtDocument(odfCanvas) {
963971 self . emit ( ops . OdtDocument . signalStepsRemoved , args ) ;
964972 } ;
965973
974+ /**
975+ * Process all signals queued up during operation execution
976+ * @return {undefined }
977+ */
978+ this . processPendingSignals = function ( ) {
979+ var signal = pendingSignals . shift ( ) ;
980+ while ( signal ) {
981+ signal ( ) ;
982+ signal = pendingSignals . shift ( ) ;
983+ }
984+ } ;
985+
966986 /**
967987 * @return {undefined }
968988 */
0 commit comments