Bug 9619 - make sure saving model in main thread
authordadubrow
Thu, 13 Aug 2009 14:40:37 -0500
changeset 437 d19f4087230d
parent 436 f963b9801067
child 438 1137da10d4e5
Bug 9619 - make sure saving model in main thread
uidesigner/com.nokia.sdt.symbian/src/com/nokia/sdt/symbian/updater/DesignRefactoring.java
--- a/uidesigner/com.nokia.sdt.symbian/src/com/nokia/sdt/symbian/updater/DesignRefactoring.java	Thu Aug 13 14:21:16 2009 -0500
+++ b/uidesigner/com.nokia.sdt.symbian/src/com/nokia/sdt/symbian/updater/DesignRefactoring.java	Thu Aug 13 14:40:37 2009 -0500
@@ -28,6 +28,7 @@
 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
 import org.eclipse.swt.widgets.Display;
 
+import com.nokia.cpp.internal.api.utils.core.Logging;
 import com.nokia.sdt.datamodel.IDesignerDataModel;
 import com.nokia.sdt.emf.dm.IComponentManifest;
 import com.nokia.sdt.emf.dm.IDesignerData;
@@ -36,6 +37,7 @@
 import com.nokia.sdt.sourcegen.ISourceGenUpgradingProvider;
 import com.nokia.sdt.sourcegen.PatchContext;
 import com.nokia.sdt.sourcegen.SourceGenUpdatingRefactoring;
+import com.nokia.sdt.symbian.SymbianPlugin;
 import com.nokia.sdt.symbian.dm.ComponentManifestSourceGenVersionProvider;
 import com.nokia.sdt.symbian.dm.DesignerDataModel;
 import com.nokia.sdt.workspace.IProjectContext;
@@ -202,7 +204,7 @@
 		 * @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
 		 */
 		@Override
-		public Change perform(IProgressMonitor pm) throws CoreException {
+		public Change perform(final IProgressMonitor pm) throws CoreException {
 			if (session != null) {
 				// now save any patched sources
 				session.getSourceGenProvider().saveGeneratedSources(pm);
@@ -211,12 +213,16 @@
 				session.setUpgradingMode(false);
 			}
 			
-			// and save model based on patched sources
-			try {
-				model.saveModel(pm);
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
+			Display.getDefault().syncExec(new Runnable() {
+				public void run() {
+					// and save model based on patched sources
+					try {
+						model.saveModel(pm);
+					} catch (Exception e) {
+						Logging.log(SymbianPlugin.getDefault(), Logging.newSimpleStatus(0, e));
+					}
+				}
+			});
 			
 			// not undoable
 			return null;