RepreZen / KaiZen-OpenAPI-Editor

Eclipse Editor for the Swagger-OpenAPI Description Language
Eclipse Public License 1.0
115 stars 12 forks source link

ZEN-4351 Invalid Thread Access Exception thrown when saving document and other fixes #458

Closed tfesenko closed 6 years ago

tfesenko commented 6 years ago

Improvements:

ZEN-4351 Invalid Thread Access Exception thrown when saving documents

Monitor.isCancelled() and the Main Thread.

Normally, monitor.isCancelled() should NOT be executed in the Main thread - that's the idea of the progress monitor.

However, the save operations use a special implementation of the progress monitor (EventLoopProgressMonitor) which is

used to run an event loop whenever progress monitor methods are invoked

That's why isCancelled() operation must be executed in the Main Thread for this implementation of the monitor.

org.eclipse.ui.internal.SaveableHelper.saveModels() creates and EventLoopProgressMonitor, then it calls doSaveModel() which calls the editor's save method (model.doSave(subMonitor.split(2), shellProvider);). This is how our doSave() methods gets this implementation of the monitor and passes it to the validation.