mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
load application and project inside a transaction
This commit is contained in:
@@ -342,29 +342,16 @@ public class IdeaApplication {
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
|
||||
app.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Project projectFromCommandLine = null;
|
||||
if (myPerformProjectLoad) {
|
||||
projectFromCommandLine = loadProjectFromExternalCommandLine();
|
||||
}
|
||||
TransactionGuard.submitTransaction(app, () -> {
|
||||
Project projectFromCommandLine = myPerformProjectLoad ? loadProjectFromExternalCommandLine() : null;
|
||||
app.getMessageBus().syncPublisher(AppLifecycleListener.TOPIC).appStarting(projectFromCommandLine);
|
||||
|
||||
final MessageBus bus = ApplicationManager.getApplication().getMessageBus();
|
||||
bus.syncPublisher(AppLifecycleListener.TOPIC).appStarting(projectFromCommandLine);
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(PluginManager::reportPluginError);
|
||||
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PluginManager.reportPluginError();
|
||||
}
|
||||
});
|
||||
|
||||
//safe for headless and unit test modes
|
||||
UsageTrigger.trigger(app.getName() + "app.started");
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
//safe for headless and unit test modes
|
||||
UsageTrigger.trigger(app.getName() + "app.started");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-49
@@ -229,8 +229,8 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
|
||||
succeed = true;
|
||||
}
|
||||
finally {
|
||||
if (!succeed) {
|
||||
scheduleDispose(project);
|
||||
if (!succeed && !project.isDefault()) {
|
||||
TransactionGuard.submitTransaction(project, () -> WriteAction.run(() -> Disposer.dispose(project)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,26 +244,6 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private static void scheduleDispose(@NotNull final ProjectImpl project) {
|
||||
if (project.isDefault()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!project.isDisposed()) {
|
||||
Disposer.dispose(project);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Project loadProject(@NotNull String filePath) throws IOException {
|
||||
@@ -347,31 +327,24 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
|
||||
return false;
|
||||
}
|
||||
|
||||
try (AccessToken ignored = TransactionGuard.getInstance().startSynchronousTransaction(TransactionKind.ANY_CHANGE)) {
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () ->
|
||||
DumbService.getInstance(project).queueTask(new DumbModeTask() {
|
||||
@Override
|
||||
public void performInDumbMode(@NotNull ProgressIndicator indicator) {
|
||||
waitForFileWatcher(indicator);
|
||||
}
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () ->
|
||||
DumbService.getInstance(project).queueTask(new DumbModeTask() {
|
||||
@Override
|
||||
public void performInDumbMode(@NotNull ProgressIndicator indicator) {
|
||||
waitForFileWatcher(indicator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "wait for file watcher";
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "wait for file watcher";
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
Runnable process = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fireProjectOpened(project);
|
||||
}
|
||||
});
|
||||
TransactionGuard.getInstance().submitTransactionAndWait(() -> fireProjectOpened(project));
|
||||
|
||||
StartupManagerImpl startupManager = (StartupManagerImpl)StartupManager.getInstance(project);
|
||||
startupManager.runStartupActivities();
|
||||
@@ -468,12 +441,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
|
||||
return null;
|
||||
}
|
||||
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
openProject(project);
|
||||
}
|
||||
});
|
||||
TransactionGuard.getInstance().submitTransactionAndWait(() -> openProject(project));
|
||||
return project;
|
||||
}
|
||||
});
|
||||
@@ -637,7 +605,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
|
||||
if (checkCanClose && !canClose(project)) return false;
|
||||
final ShutDownTracker shutDownTracker = ShutDownTracker.getInstance();
|
||||
shutDownTracker.registerStopperThread(Thread.currentThread());
|
||||
try (AccessToken ignored = TransactionGuard.getInstance().startSynchronousTransaction(TransactionKind.ANY_CHANGE)) {
|
||||
try {
|
||||
if (save) {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
project.save();
|
||||
|
||||
Reference in New Issue
Block a user