Skip to content

Commit

Permalink
улучшено лагирование и добавлена чистка воркспейса от открытыз файлов…
Browse files Browse the repository at this point in the history
… в случае краша рендера
  • Loading branch information
JavaSaBr committed Jun 18, 2016
1 parent 3f5a3a1 commit 4b6c902
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
7 changes: 7 additions & 0 deletions src/com/ss/editor/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.jme3.post.filters.FXAAFilter;
import com.jme3.post.filters.ToneMapFilter;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RendererException;
import com.jme3.scene.Node;
import com.jme3.system.AppSettings;
import com.jme3x.jfx.JmeFxContainer;
Expand Down Expand Up @@ -356,6 +357,12 @@ public void update() {
final WorkspaceManager workspaceManager = WorkspaceManager.getInstance();
workspaceManager.save();
System.exit(1);
} catch (final RendererException e) {
LOGGER.warning(e);
final WorkspaceManager workspaceManager = WorkspaceManager.getInstance();
workspaceManager.clear();
workspaceManager.save();
System.exit(1);
} finally {
syncUnlock(stamp);
}
Expand Down
8 changes: 8 additions & 0 deletions src/com/ss/editor/manager/WorkspaceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ public synchronized Workspace getWorkspace(final Path assetFolder) {
return workspace;
}

/**
* Очистить воркспейсы.
*/
public synchronized void clear() {
final ObjectDictionary<Path, Workspace> workspaces = getWorkspaces();
workspaces.forEach(Workspace::save);
}

/**
* Сохранить воркспейсы.
*/
Expand Down
12 changes: 8 additions & 4 deletions src/com/ss/editor/model/workspace/Workspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,18 @@ private void incrementChanges() {
changes.incrementAndGet();
}

/**
* Очистка воркспейса.
*/
public void clear() {
getOpenedFiles().clear();
}

/**
* Сохранение состояния в файл.
*/
public void save() {

if (changes.get() == 0) {
return;
}
if (changes.get() == 0) return;

final Path assetFolder = getAssetFolder();
final Path workspaceFile = assetFolder.resolve(WorkspaceManager.FOLDER_EDITOR).resolve(WorkspaceManager.FILE_WORKSPACE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ protected void createToolbar(final HBox container) {
* Обработка смны Bucket типа.
*/
private void changeBucketType(final RenderQueue.Bucket newValue) {

final MaterialEditorState editorState = getEditorState();
editorState.changeBucketType(newValue);
}
Expand All @@ -509,11 +508,7 @@ private void changeBucketType(final RenderQueue.Bucket newValue) {
* Обработка смены типа материала.
*/
private void changeType(final String newType) {

if (isIgnoreListeners()) {
return;
}

if (isIgnoreListeners()) return;
processChangeTypeImpl(newType);
}

Expand Down Expand Up @@ -570,10 +565,7 @@ private ToggleButton getSphereButton() {
* Обработка смены режима модели.
*/
private void changeModelType(final ToggleButton button, final Boolean newValue) {

if (newValue == Boolean.FALSE) {
return;
}
if (newValue == Boolean.FALSE) return;

final MaterialEditorState editorState = getEditorState();

Expand Down

0 comments on commit 4b6c902

Please sign in to comment.