Merge "Fix regression in PFD#fromData" into qt-r1-dev
This commit is contained in:
@@ -581,12 +581,16 @@ public class ParcelFileDescriptor implements Parcelable, Closeable {
|
|||||||
public static ParcelFileDescriptor fromData(byte[] data, String name) throws IOException {
|
public static ParcelFileDescriptor fromData(byte[] data, String name) throws IOException {
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
MemoryFile file = new MemoryFile(name, data.length);
|
MemoryFile file = new MemoryFile(name, data.length);
|
||||||
|
try {
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
file.writeBytes(data, 0, 0, data.length);
|
file.writeBytes(data, 0, 0, data.length);
|
||||||
}
|
}
|
||||||
file.deactivate();
|
file.deactivate();
|
||||||
FileDescriptor fd = file.getFileDescriptor();
|
FileDescriptor fd = file.getFileDescriptor();
|
||||||
return fd != null ? ParcelFileDescriptor.dup(fd) : null;
|
return fd != null ? ParcelFileDescriptor.dup(fd) : null;
|
||||||
|
} finally {
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user