tdf#122543: Ignore duplicate calls to loadFromContents on same Document
diff --git a/ios/Mobile/Document.mm b/ios/Mobile/Document.mm
index 70d130d..73ecd67 100644
--- a/ios/Mobile/Document.mm
+++ b/ios/Mobile/Document.mm
@@ -49,6 +49,11 @@
- (BOOL)loadFromContents:(id)contents ofType:(NSString *)typeName error:(NSError **)errorPtr {
// If this method is called a second time on the same Document object, just ignore it. This
// seems to happen occastionally when the device is awakened after sleep. See tdf#122543.
if (fakeClientFd >= 0)
return YES;
fakeClientFd = fakeSocketSocket();
NSString *uri = [[self fileURL] absoluteString];
diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm
index 9a4503b..1d70b28 100644
--- a/ios/Mobile/DocumentViewController.mm
+++ b/ios/Mobile/DocumentViewController.mm
@@ -203,6 +203,12 @@
}
if (p[0].revents == POLLIN) {
int n = fakeSocketAvailableDataLength(self.document->fakeClientFd);
// I don't want to check for n being -1 here, even if
// that will lead to a crash (std::length_error from the
// below std::vector constructor), as n being -1 is a
// sign of something being wrong elsewhere anyway, and I
// prefer to fix the root cause. Let's see how well this
// works out. See tdf#122543 for such a case.
if (n == 0)
return;
std::vector<char> buf(n);