aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-09-11 12:49:13 -0700
committerandroid code review <noreply-gerritcodereview@google.com>2012-09-11 12:49:13 -0700
commitb1fe0b62289fd3ed2fb51eace4325773fa7dd144 (patch)
tree2efdc16860b6ec6ef496624b05c10bcae5343893
parentb081e294e4b217f956b969a12400ea3f920cef41 (diff)
parent54aba95cbf277c06f1aeae31d6e2952a1dd6769f (diff)
downloadsdk-b1fe0b62289fd3ed2fb51eace4325773fa7dd144.zip
sdk-b1fe0b62289fd3ed2fb51eace4325773fa7dd144.tar.gz
sdk-b1fe0b62289fd3ed2fb51eace4325773fa7dd144.tar.bz2
Merge "Attempt to work around XML editor state bug"
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
index 465c1e6..6098483 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
@@ -49,6 +49,7 @@ import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -940,7 +941,20 @@ public abstract class AndroidXmlEditor extends FormEditor {
* @param undoLabel if non null, the edit action will be run as a single undo event
* and the label used as the name of the undoable action
*/
- private final void wrapEditXmlModel(Runnable editAction, String undoLabel) {
+ private final void wrapEditXmlModel(final Runnable editAction, final String undoLabel) {
+ Display display = mTextEditor.getSite().getShell().getDisplay();
+ if (display.getThread() != Thread.currentThread()) {
+ display.syncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (!mTextEditor.getTextViewer().getControl().isDisposed()) {
+ wrapEditXmlModel(editAction, undoLabel);
+ }
+ }
+ });
+ return;
+ }
+
IStructuredModel model = null;
int undoReverseCount = 0;
try {
@@ -955,7 +969,7 @@ public abstract class AndroidXmlEditor extends FormEditor {
// own -- see http://code.google.com/p/android/issues/detail?id=15901
// for one such call chain. By nesting these calls several times
// we've incrementing the command count such that a couple of
- // cancellations are ignored. Interfering which this mechanism may
+ // cancellations are ignored. Interfering with this mechanism may
// sound dangerous, but it appears that this undo-termination is
// done for UI reasons to anticipate what the user wants, and we know
// that in *our* scenarios we want the entire unit run as a single
@@ -995,8 +1009,6 @@ public abstract class AndroidXmlEditor extends FormEditor {
boolean oldIgnore = mIgnoreXmlUpdate;
try {
mIgnoreXmlUpdate = true;
- // Notify the model we're done modifying it. This must *always* be executed.
- model.changedModel();
if (AdtPrefs.getPrefs().getFormatGuiXml() && mFormatNode != null) {
if (mFormatNode == getUiRootNode()) {
@@ -1020,6 +1032,9 @@ public abstract class AndroidXmlEditor extends FormEditor {
mFormatChildren = false;
}
+ // Notify the model we're done modifying it. This must *always* be executed.
+ model.changedModel();
+
// Clean up the undo unit. This is done more than once as explained
// above for beginRecording.
for (int i = 0; i < undoReverseCount; i++) {