Merge "Fix 3122139, where previewing an attachment for the second time will fail."

This commit is contained in:
Wei-Ta Chen
2010-10-22 11:22:59 -07:00
committed by Android (Google) Code Review

View File

@@ -65,6 +65,7 @@ static SkMemoryStream* buildSkMemoryStream(SkStream *stream) {
}
}
data = (char*)sk_realloc_throw(data, streamLen);
SkMemoryStream* streamMem = new SkMemoryStream();
streamMem->setMemoryOwned(data, streamLen);
return streamMem;
@@ -133,6 +134,12 @@ static jobject nativeNewInstanceFromFileDescriptor(JNIEnv* env, jobject clazz,
}
stream = fdStream;
} else {
/* Restore our offset when we leave, so we can be called more than once
with the same descriptor. This is only required if we didn't dup the
file descriptor, but it is OK to do it all the time.
*/
AutoFDSeek as(descriptor);
SkFDStream* fdStream = new SkFDStream(descriptor, false);
if (!fdStream->isValid()) {
fdStream->unref();
@@ -142,12 +149,6 @@ static jobject nativeNewInstanceFromFileDescriptor(JNIEnv* env, jobject clazz,
fdStream->unref();
}
/* Restore our offset when we leave, so we can be called more than once
with the same descriptor. This is only required if we didn't dup the
file descriptor, but it is OK to do it all the time.
*/
AutoFDSeek as(descriptor);
return doBuildTileIndex(env, stream);
}