Skip to content

Commit

Permalink
Merge pull request #3165 from @PS-Soundwave
Browse files Browse the repository at this point in the history
Fix typos and wildcard error in EnvironmentSwitchHandler
  • Loading branch information
oniatus authored Dec 21, 2017
2 parents 6eaf991 + 99d0ca3 commit 6b228e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public final class EnvironmentSwitchHandler {
public EnvironmentSwitchHandler() {
}

@SuppressWarnings("unchecked")
public void handleSwitchToGameEnvironment(Context context) {
ModuleManager moduleManager = context.get(ModuleManager.class);

Expand All @@ -75,11 +76,7 @@ public void handleSwitchToGameEnvironment(Context context) {
}
Class<?> targetType = ReflectionUtil.getTypeParameterForSuper(copyStrategy, CopyStrategy.class, 0);
if (targetType != null) {
try {
copyStrategyLibrary.register(targetType, copyStrategy.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
logger.error("Cannot register CopyStrategy '{}' - failed to instantiate", copyStrategy, e);
}
registerCopyStrategy(copyStrategyLibrary, targetType, copyStrategy);
} else {
logger.error("Cannot register CopyStrategy '{}' - unable to determine target type", copyStrategy);
}
Expand Down Expand Up @@ -107,7 +104,7 @@ public void handleSwitchToGameEnvironment(Context context) {
ModuleAwareAssetTypeManager assetTypeManager = context.get(ModuleAwareAssetTypeManager.class);

/*
* The registring of the prefab formats is done in this method, because it needs to be done before
* The registering of the prefab formats is done in this method, because it needs to be done before
* the environment of the asset manager gets changed.
*
* It can't be done before this method gets called because the ComponentLibrary isn't
Expand All @@ -123,6 +120,14 @@ public void handleSwitchToGameEnvironment(Context context) {

}

private <T, U extends CopyStrategy<T>> void registerCopyStrategy(CopyStrategyLibrary copyStrategyLibrary, Class<T> type, Class<U> strategy) {
try {
copyStrategyLibrary.register(type, strategy.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
logger.error("Cannot register CopyStrategy '{}' - failed to instantiate", strategy, e);
}
}

/**
* Switches the environment of the asset manager to the specified one. It does not register the prefab formats
* as they require a proper ComponentLibrary.
Expand Down Expand Up @@ -153,7 +158,7 @@ public void handleSwitchBackFromPreviewEnvironment(Context context) {
}


public void handleSwitchToEmptyEnivronment(Context context) {
public void handleSwitchToEmptyEnvironment(Context context) {
ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
cheapAssetManagerUpdate(context, environment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void dispose(boolean shuttingDown) {
ModuleEnvironment oldEnvironment = context.get(ModuleManager.class).getEnvironment();
context.get(ModuleManager.class).loadEnvironment(Collections.<Module>emptySet(), true);
if (!shuttingDown) {
context.get(EnvironmentSwitchHandler.class).handleSwitchToEmptyEnivronment(context);
context.get(EnvironmentSwitchHandler.class).handleSwitchToEmptyEnvironment(context);
}
if (oldEnvironment != null) {
oldEnvironment.close();
Expand Down

0 comments on commit 6b228e0

Please sign in to comment.