ios/Mobile/AppDelegate.h | 1 - ios/Mobile/AppDelegate.mm | 6 ------ ios/Mobile/TemplateCollectionViewController.mm | 5 +++++ 3 files changed, 5 insertions(+), 7 deletions(-)
New commits: commit e2f48faf1441d88e545ff87b42a90a14bfcc04ac Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Thu Mar 28 17:04:58 2019 +0200 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Thu Mar 28 17:28:26 2019 +0200 tdf#123742: Fix lifecycle issues for the "Office" object Because of the use of std::shared_ptr in lokit_main(), the (singleton) lok::Office (or LibLibreOffice_Impl) object gets destroyed when lokit_main() exits. We shouldn't keep our own copy of a raw pointer to it around. Just call lok_init_2() to get the pointer where we need it. We don't need to call lok_init_2() already in -[AppDelegate application:didFinishLaunchingWithOptions:]. diff --git a/ios/Mobile/AppDelegate.h b/ios/Mobile/AppDelegate.h index d9c6c00cc..58c09bf46 100644 --- a/ios/Mobile/AppDelegate.h +++ b/ios/Mobile/AppDelegate.h @@ -17,7 +17,6 @@ @end extern NSString *app_locale; -extern LibreOfficeKit *lo_kit; // vim:set shiftwidth=4 softtabstop=4 expandtab: diff --git a/ios/Mobile/AppDelegate.mm b/ios/Mobile/AppDelegate.mm index 001f0f5c7..b67caf194 100644 --- a/ios/Mobile/AppDelegate.mm +++ b/ios/Mobile/AppDelegate.mm @@ -27,7 +27,6 @@ static LOOLWSD *loolwsd = nullptr; NSString *app_locale; -LibreOfficeKit *lo_kit; static void download(NSURL *source, NSURL *destination) { [[[NSURLSession sharedSession] downloadTaskWithURL:source @@ -184,11 +183,6 @@ static void updateTemplates(NSData *data, NSURLResponse *response) } } - // Initialize LibreOfficeKit. - - lo_kit = lok_init_2(nullptr, nullptr); - lo_kit->pClass->registerCallback(lo_kit, [](int, const char *, void*){}, nullptr); - fakeSocketSetLoggingCallback([](const std::string& line) { LOG_TRC_NOFILE(line); diff --git a/ios/Mobile/TemplateCollectionViewController.mm b/ios/Mobile/TemplateCollectionViewController.mm index c5da8ef05..a31f3a655 100644 --- a/ios/Mobile/TemplateCollectionViewController.mm +++ b/ios/Mobile/TemplateCollectionViewController.mm @@ -8,6 +8,8 @@ #import "svtools/strings.hrc" +#import <LibreOfficeKit/LibreOfficeKitInit.h> + #import "AppDelegate.h" #import "L10n.h" #import "TemplateCollectionViewController.h" @@ -136,8 +138,11 @@ static NSString *mapTemplateExtensionToActual(NSString *templateName) { NSURL *newURL = [cacheDirectory URLByAppendingPathComponent:mapTemplateExtensionToActual(selectedTemplate.lastPathComponent) isDirectory:NO]; + LibreOfficeKit *lo_kit = lok_init_2(nullptr, nullptr); + // Load the template into LibreOffice core, save as the corresponding document type (with the // same basename), and then proceed to edit that. + LibreOfficeKitDocument *doc = lo_kit->pClass->documentLoad(lo_kit, [[selectedTemplate absoluteString] UTF8String]); doc->pClass->saveAs(doc, [[newURL absoluteString] UTF8String], nullptr, nullptr); doc->pClass->destroy(doc); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits