@@ -68,6 +68,7 @@ public CharsetManagerJob() {
68
68
super (Messages .resources_charsetUpdating );
69
69
setSystem (true );
70
70
setPriority (Job .INTERACTIVE );
71
+ setRule (workspace .getRoot ());
71
72
}
72
73
73
74
@ Override
@@ -102,7 +103,7 @@ protected IStatus run(IProgressMonitor monitor) {
102
103
workspace .prepareOperation (rule , monitor );
103
104
workspace .beginOperation (true );
104
105
Map .Entry <IProject , Boolean > next ;
105
- while (( next = getNextChange ()) != null ) {
106
+ while (! monitor . isCanceled () && (( next = getNextChange ()) != null ) ) {
106
107
//just exit if the system is shutting down or has been shut down
107
108
//it is too late to change the workspace at this point anyway
108
109
if (systemBundle .getState () != Bundle .ACTIVE )
@@ -143,6 +144,16 @@ public boolean shouldRun() {
143
144
return !asyncChanges .isEmpty ();
144
145
}
145
146
}
147
+
148
+ public void shutDown () {
149
+ cancel ();
150
+ wakeUp ();
151
+ try {
152
+ join (3000 , null );
153
+ } catch (OperationCanceledException | InterruptedException ignored ) {
154
+ // nothing
155
+ }
156
+ }
146
157
}
147
158
148
159
private class ResourceChangeListener implements IResourceChangeListener {
@@ -495,6 +506,9 @@ private void setCharsetForHasFailed(IPath resourcePath, BackingStoreException e)
495
506
496
507
@ Override
497
508
public void shutdown (IProgressMonitor monitor ) {
509
+ if (job != null ) {
510
+ job .shutDown ();
511
+ }
498
512
InstanceScope .INSTANCE .getNode (ResourcesPlugin .PI_RESOURCES )
499
513
.removePreferenceChangeListener (preferenceChangeListener );
500
514
0 commit comments