From 9ea4f537d4b0e9aba6c635473c5211d8121a245b Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 14 Jun 2019 15:14:34 +0200 Subject: [PATCH] android: No need to have the loolwsd instance static. When we don't treat it as static anyway... Change-Id: I165c06390882cfb9870c338a361ec3c5216985c7 --- android/app/src/main/cpp/androidapp.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/android/app/src/main/cpp/androidapp.cpp b/android/app/src/main/cpp/androidapp.cpp index 126092ac1..bc4666392 100644 --- a/android/app/src/main/cpp/androidapp.cpp +++ b/android/app/src/main/cpp/androidapp.cpp @@ -30,7 +30,6 @@ const int SHOW_JS_MAXLEN = 70; int loolwsd_server_socket_fd = -1; static std::string fileURL; -static LOOLWSD *loolwsd = nullptr; static int fakeClientFd; static int closeNotificationPipeForForwardingThread[2]; static JavaVM* javaVM = nullptr; @@ -267,7 +266,6 @@ Java_org_libreoffice_androidapp_MainActivity_createLOOLWSD(JNIEnv *env, jobject, std::thread([] { - assert(loolwsd == nullptr); char *argv[2]; argv[0] = strdup("mobile"); argv[1] = nullptr; @@ -275,9 +273,10 @@ Java_org_libreoffice_androidapp_MainActivity_createLOOLWSD(JNIEnv *env, jobject, while (true) { LOG_DBG("Creating LOOLWSD"); - loolwsd = new LOOLWSD(); - loolwsd->run(1, argv); - delete loolwsd; + { + std::unique_ptr loolwsd(new LOOLWSD()); + loolwsd->run(1, argv); + } LOG_DBG("One run of LOOLWSD completed"); std::this_thread::sleep_for(std::chrono::milliseconds(100)); }