SDK:
- Don't lock files when only reading in AssetDataObjects / subclasses git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10329 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
53a4d896c0
commit
76bc2bb6e5
@ -74,9 +74,7 @@ public abstract class AbstractBlenderImportDataObject extends SpatialAssetDataOb
|
||||
String assetKeyName = mgr.getRelativeAssetPath(outFile.getPath());
|
||||
BlenderKey key = new BlenderKey(assetKeyName);
|
||||
Beans.copyProperties(key, getAssetKey());
|
||||
FileLock lock = null;
|
||||
try {
|
||||
lock = getPrimaryFile().lock();
|
||||
listListener.start();
|
||||
Spatial spatial = mgr.loadModel(key);
|
||||
replaceFiles();
|
||||
@ -85,12 +83,9 @@ public abstract class AbstractBlenderImportDataObject extends SpatialAssetDataOb
|
||||
savable = spatial;
|
||||
logger.log(Level.INFO, "Loaded asset {0}", getName());
|
||||
return spatial;
|
||||
} catch (IOException ex) {
|
||||
} catch (Exception ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
lock.releaseLock();
|
||||
}
|
||||
try {
|
||||
outFile.delete();
|
||||
} catch (IOException ex) {
|
||||
|
@ -220,7 +220,7 @@ public class AssetDataObject extends MultiDataObject {
|
||||
ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Saving File..");
|
||||
progressHandle.start();
|
||||
BinaryExporter exp = BinaryExporter.getInstance();
|
||||
FileLock lock = null;
|
||||
// FileLock lock = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
if (saveExtension == null) {
|
||||
@ -235,16 +235,16 @@ public class AssetDataObject extends MultiDataObject {
|
||||
}
|
||||
exp.save(savable, out);
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
lock.releaseLock();
|
||||
}
|
||||
// if (lock != null) {
|
||||
// lock.releaseLock();
|
||||
// }
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
progressHandle.finish();
|
||||
setModified(false);
|
||||
logger.log(LogLevel.USERINFO, "File {0} saved successfully", getPrimaryFile().getNameExt());
|
||||
logger.log(Level.INFO, "File {0} saved successfully", getPrimaryFile().getNameExt());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,25 +89,18 @@ public class SpatialAssetDataObject extends AssetDataObject {
|
||||
}
|
||||
//make sure its actually closed and all data gets reloaded
|
||||
closeAsset();
|
||||
FileLock lock = null;
|
||||
try {
|
||||
lock = getPrimaryFile().lock();
|
||||
listListener.start();
|
||||
Spatial spatial = mgr.loadModel(getAssetKey());
|
||||
listListener.stop();
|
||||
if (!(this instanceof BinaryModelDataObject)) {
|
||||
SpatialUtil.storeOriginalPathUserData(spatial);
|
||||
}
|
||||
lock.releaseLock();
|
||||
savable = spatial;
|
||||
logger.log(Level.INFO, "Loaded asset {0}", getName());
|
||||
return spatial;
|
||||
} catch (Exception ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
lock.releaseLock();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -42,47 +42,36 @@ public class OgreBinaryMeshDataObject extends SpatialAssetDataObject {
|
||||
}
|
||||
//make sure its actually closed and all data gets reloaded
|
||||
closeAsset();
|
||||
ProgressHandle handle = ProgressHandleFactory.createHandle("Converting OgreBinary");
|
||||
handle.start();
|
||||
//mesh
|
||||
OgreXMLConvertOptions options = new OgreXMLConvertOptions(getPrimaryFile().getPath());
|
||||
options.setBinaryFile(true);
|
||||
OgreXMLConvert conv = new OgreXMLConvert();
|
||||
conv.doConvert(options, handle);
|
||||
conv.doConvert(options, null);
|
||||
//try skeleton
|
||||
if (getPrimaryFile().existsExt("skeleton")) {
|
||||
OgreXMLConvertOptions options2 = new OgreXMLConvertOptions(getPrimaryFile().getParent().getFileObject(getPrimaryFile().getName(), "skeleton").getPath());
|
||||
options2.setBinaryFile(true);
|
||||
OgreXMLConvert conv2 = new OgreXMLConvert();
|
||||
conv2.doConvert(options2, handle);
|
||||
conv2.doConvert(options2, null);
|
||||
}
|
||||
handle.progress("Convert Model");
|
||||
String assetKey = mgr.getRelativeAssetPath(options.getDestFile());
|
||||
FileLock lock = null;
|
||||
try {
|
||||
lock = getPrimaryFile().lock();
|
||||
listListener.start();
|
||||
Spatial spatial = mgr.loadModel(assetKey);
|
||||
//replace transient xml files in list of assets for this model
|
||||
replaceXmlFiles(mgr);
|
||||
listListener.stop();
|
||||
SpatialUtil.storeOriginalPathUserData(spatial);
|
||||
lock.releaseLock();
|
||||
File deleteFile = new File(options.getDestFile());
|
||||
deleteFile.delete();
|
||||
handle.finish();
|
||||
savable = spatial;
|
||||
logger.log(Level.INFO, "Loaded asset {0}", getName());
|
||||
return spatial;
|
||||
} catch (IOException ex) {
|
||||
} catch (Exception ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
if (lock != null) {
|
||||
lock.releaseLock();
|
||||
}
|
||||
}
|
||||
File deleteFile = new File(options.getDestFile());
|
||||
deleteFile.delete();
|
||||
handle.finish();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user