- 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
3.0
nor..67 12 years ago
parent 53a4d896c0
commit 76bc2bb6e5
  1. 7
      sdk/jme3-blender/src/com/jme3/gde/blender/filetypes/AbstractBlenderImportDataObject.java
  2. 10
      sdk/jme3-core/src/com/jme3/gde/core/assets/AssetDataObject.java
  3. 7
      sdk/jme3-core/src/com/jme3/gde/core/assets/SpatialAssetDataObject.java
  4. 17
      sdk/jme3-ogretools/src/com/jme3/gde/ogretools/OgreBinaryMeshDataObject.java

@ -74,9 +74,7 @@ public abstract class AbstractBlenderImportDataObject extends SpatialAssetDataOb
String assetKeyName = mgr.getRelativeAssetPath(outFile.getPath()); String assetKeyName = mgr.getRelativeAssetPath(outFile.getPath());
BlenderKey key = new BlenderKey(assetKeyName); BlenderKey key = new BlenderKey(assetKeyName);
Beans.copyProperties(key, getAssetKey()); Beans.copyProperties(key, getAssetKey());
FileLock lock = null;
try { try {
lock = getPrimaryFile().lock();
listListener.start(); listListener.start();
Spatial spatial = mgr.loadModel(key); Spatial spatial = mgr.loadModel(key);
replaceFiles(); replaceFiles();
@ -85,12 +83,9 @@ public abstract class AbstractBlenderImportDataObject extends SpatialAssetDataOb
savable = spatial; savable = spatial;
logger.log(Level.INFO, "Loaded asset {0}", getName()); logger.log(Level.INFO, "Loaded asset {0}", getName());
return spatial; return spatial;
} catch (IOException ex) { } catch (Exception ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} finally { } finally {
if (lock != null) {
lock.releaseLock();
}
try { try {
outFile.delete(); outFile.delete();
} catch (IOException ex) { } catch (IOException ex) {

@ -220,7 +220,7 @@ public class AssetDataObject extends MultiDataObject {
ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Saving File.."); ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Saving File..");
progressHandle.start(); progressHandle.start();
BinaryExporter exp = BinaryExporter.getInstance(); BinaryExporter exp = BinaryExporter.getInstance();
FileLock lock = null; // FileLock lock = null;
OutputStream out = null; OutputStream out = null;
try { try {
if (saveExtension == null) { if (saveExtension == null) {
@ -235,16 +235,16 @@ public class AssetDataObject extends MultiDataObject {
} }
exp.save(savable, out); exp.save(savable, out);
} finally { } finally {
if (lock != null) { // if (lock != null) {
lock.releaseLock(); // lock.releaseLock();
} // }
if (out != null) { if (out != null) {
out.close(); out.close();
} }
} }
progressHandle.finish(); progressHandle.finish();
setModified(false); 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 //make sure its actually closed and all data gets reloaded
closeAsset(); closeAsset();
FileLock lock = null;
try { try {
lock = getPrimaryFile().lock();
listListener.start(); listListener.start();
Spatial spatial = mgr.loadModel(getAssetKey()); Spatial spatial = mgr.loadModel(getAssetKey());
listListener.stop(); listListener.stop();
if (!(this instanceof BinaryModelDataObject)) { if (!(this instanceof BinaryModelDataObject)) {
SpatialUtil.storeOriginalPathUserData(spatial); SpatialUtil.storeOriginalPathUserData(spatial);
} }
lock.releaseLock();
savable = spatial; savable = spatial;
logger.log(Level.INFO, "Loaded asset {0}", getName()); logger.log(Level.INFO, "Loaded asset {0}", getName());
return spatial; return spatial;
} catch (Exception ex) { } catch (Exception ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} finally {
if (lock != null) {
lock.releaseLock();
}
} }
return null; return null;
} }

@ -42,47 +42,36 @@ public class OgreBinaryMeshDataObject extends SpatialAssetDataObject {
} }
//make sure its actually closed and all data gets reloaded //make sure its actually closed and all data gets reloaded
closeAsset(); closeAsset();
ProgressHandle handle = ProgressHandleFactory.createHandle("Converting OgreBinary");
handle.start();
//mesh //mesh
OgreXMLConvertOptions options = new OgreXMLConvertOptions(getPrimaryFile().getPath()); OgreXMLConvertOptions options = new OgreXMLConvertOptions(getPrimaryFile().getPath());
options.setBinaryFile(true); options.setBinaryFile(true);
OgreXMLConvert conv = new OgreXMLConvert(); OgreXMLConvert conv = new OgreXMLConvert();
conv.doConvert(options, handle); conv.doConvert(options, null);
//try skeleton //try skeleton
if (getPrimaryFile().existsExt("skeleton")) { if (getPrimaryFile().existsExt("skeleton")) {
OgreXMLConvertOptions options2 = new OgreXMLConvertOptions(getPrimaryFile().getParent().getFileObject(getPrimaryFile().getName(), "skeleton").getPath()); OgreXMLConvertOptions options2 = new OgreXMLConvertOptions(getPrimaryFile().getParent().getFileObject(getPrimaryFile().getName(), "skeleton").getPath());
options2.setBinaryFile(true); options2.setBinaryFile(true);
OgreXMLConvert conv2 = new OgreXMLConvert(); OgreXMLConvert conv2 = new OgreXMLConvert();
conv2.doConvert(options2, handle); conv2.doConvert(options2, null);
} }
handle.progress("Convert Model");
String assetKey = mgr.getRelativeAssetPath(options.getDestFile()); String assetKey = mgr.getRelativeAssetPath(options.getDestFile());
FileLock lock = null;
try { try {
lock = getPrimaryFile().lock();
listListener.start(); listListener.start();
Spatial spatial = mgr.loadModel(assetKey); Spatial spatial = mgr.loadModel(assetKey);
//replace transient xml files in list of assets for this model //replace transient xml files in list of assets for this model
replaceXmlFiles(mgr); replaceXmlFiles(mgr);
listListener.stop(); listListener.stop();
SpatialUtil.storeOriginalPathUserData(spatial); SpatialUtil.storeOriginalPathUserData(spatial);
lock.releaseLock();
File deleteFile = new File(options.getDestFile()); File deleteFile = new File(options.getDestFile());
deleteFile.delete(); deleteFile.delete();
handle.finish();
savable = spatial; savable = spatial;
logger.log(Level.INFO, "Loaded asset {0}", getName()); logger.log(Level.INFO, "Loaded asset {0}", getName());
return spatial; return spatial;
} catch (IOException ex) { } catch (Exception ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
if (lock != null) {
lock.releaseLock();
}
} }
File deleteFile = new File(options.getDestFile()); File deleteFile = new File(options.getDestFile());
deleteFile.delete(); deleteFile.delete();
handle.finish();
return null; return null;
} }

Loading…
Cancel
Save