diff --git a/src/Wt/WAbstractItemView.C b/src/Wt/WAbstractItemView.C
index 5f43330..26f0b94 100644
--- a/src/Wt/WAbstractItemView.C
+++ b/src/Wt/WAbstractItemView.C
@@ -1035,9 +1035,6 @@ void WAbstractItemView::closeEditor(const WModelIndex& index, bool saveData)
   if (i != editedItems_.end()) {
     Editor& editor = i->second;
 
-    if (saveData || editOptions_ & SaveWhenClosed)
-      saveEditedValue(index, editor);
-
     WModelIndex closed = index;
 #ifndef WT_TARGET_JAVA
     editedItems_.erase(i);
@@ -1045,6 +1042,9 @@ void WAbstractItemView::closeEditor(const WModelIndex& index, bool saveData)
     editedItems_.erase(index);
 #endif
 
+    if (saveData || editOptions_ & SaveWhenClosed)
+      saveEditedValue(index, editor);
+    
     modelDataChanged(closed, closed);
   }
 }
