[Libreoffice-commits] online.git: ios/Mobile

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Nov 29 17:26:38 UTC 2018


 ios/Mobile/DocumentBrowserViewController.mm |    1 +
 ios/Mobile/DocumentViewController.mm        |   10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

New commits:
commit e7ef0c29f9e045acab08a9884cf36d61bd3be023
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Nov 29 19:21:49 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Nov 29 19:21:49 2018 +0200

    Fix a problem when taking a photo to insert in a document in the iOS app
    
    It turns out that the view of the DocumentViewController object is
    removed from the view hierarchy when the camera is displayed, and
    re-added after you choose to use the taken photo. Thus the
    viewWillAppear: method is called again at that stage. The Document
    object is stil quite intact, though. We should not call the Document
    object's openWithCompletionHandler: method again, as that will cause
    horrible brokenness.
    
    Change-Id: Ib79bd8f292b01a19866278c4d95a2e816dcd9235

diff --git a/ios/Mobile/DocumentBrowserViewController.mm b/ios/Mobile/DocumentBrowserViewController.mm
index 633b4353b..d7edf887a 100644
--- a/ios/Mobile/DocumentBrowserViewController.mm
+++ b/ios/Mobile/DocumentBrowserViewController.mm
@@ -69,6 +69,7 @@
     UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
     DocumentViewController *documentViewController = [storyBoard instantiateViewControllerWithIdentifier:@"DocumentViewController"];
     documentViewController.document = [[Document alloc] initWithFileURL:documentURL];
+    documentViewController.document->fakeClientFd = -1;
     documentViewController.document.viewController = documentViewController;
     [self presentViewController:documentViewController animated:YES completion:nil];
 }
diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm
index f60e31bbc..2c07e2448 100644
--- a/ios/Mobile/DocumentViewController.mm
+++ b/ios/Mobile/DocumentViewController.mm
@@ -62,11 +62,17 @@
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
 
-    // Access the document
+    // When the user uses the camer to insert a photo, when the camera is displayed, this view is
+    // removed. After the photo is taken it is then added back to the hierarchy. Our Document object
+    // is still there intact, however, so no need to re-open the document when we re-appear.
+
+    // Check whether the Document object is an already initialised one.
+    if (self.document->fakeClientFd >= 0)
+        return;
+
     [self.document openWithCompletionHandler:^(BOOL success) {
         if (success) {
             // Display the content of the document
-
         } else {
             // Make sure to handle the failed import appropriately, e.g., by presenting an error message to the user.
         }


More information about the Libreoffice-commits mailing list