[Libreoffice-commits] online.git: 2 commits - loolwsd/LOOLKit.cpp loolwsd/test

Miklos Vajna vmiklos at collabora.co.uk
Thu Jun 16 10:23:03 UTC 2016


 loolwsd/LOOLKit.cpp             |    7 +++++--
 loolwsd/test/TileCacheTests.cpp |    4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 3c32bc172482f52783c985a10211f68137759cd0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jun 16 11:42:47 2016 +0200

    LOOLKit: fix loss of callback during initializeForRendering()
    
    Impress deletes the current view and creates a new one during that call,
    so make sure at the end our registered callback is not lost. With this,
    the order matches how it's done in gtktiledviewer.
    
    This fixes the HTTPWSTest::testInsertDelete() test when per-view
    callbacks are enabled.
    
    Also remove the assert from TileCacheTests::testTileInvalidateWriter()
    that would assume something is invalidated right after load: the hope is
    that it's possible to load a document without invalidating anything...
    :-)

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index d063fc8..f63f4cb 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -901,6 +901,11 @@ private:
                 return nullptr;
             }
 
+            // initializeForRendering() should be called before
+            // registerCallback(), as the previous creates a new view in
+            // Impress.
+            _loKitDocument->initializeForRendering((renderOpts.empty() ? nullptr : renderOpts.c_str()));
+
             if (_multiView)
             {
                 Log::info("Loading view to document from URI: [" + uri + "] for session [" + sessionId + "].");
@@ -916,8 +921,6 @@ private:
             {
                 _loKitDocument->registerCallback(DocumentCallback, this);
             }
-
-            _loKitDocument->initializeForRendering((renderOpts.empty() ? nullptr : renderOpts.c_str()));
         }
         else
         {
diff --git a/loolwsd/test/TileCacheTests.cpp b/loolwsd/test/TileCacheTests.cpp
index 2cc793c..cd50d83 100644
--- a/loolwsd/test/TileCacheTests.cpp
+++ b/loolwsd/test/TileCacheTests.cpp
@@ -559,8 +559,6 @@ void TileCacheTests::testTileInvalidateWriter()
 
     auto socket = *loadDocAndGetSocket(_uri, documentURL);
 
-    CPPUNIT_ASSERT_MESSAGE("did not receive a invalidatetiles: message as expected", !getResponseMessage(socket, "invalidatetiles:").empty());
-
     std::string text = "Test. Now go 3 \"Enters\":\n\n\nNow after the enters, goes this text";
     for (char ch : text)
     {
commit 70f5b914f6e64a686edea34543380979a3fb4077
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Jun 15 18:04:57 2016 +0200

    TileCacheTests: assert before possible nullptr deref / div by zero

diff --git a/loolwsd/test/TileCacheTests.cpp b/loolwsd/test/TileCacheTests.cpp
index e79c65e..2cc793c 100644
--- a/loolwsd/test/TileCacheTests.cpp
+++ b/loolwsd/test/TileCacheTests.cpp
@@ -400,6 +400,7 @@ void readTileData(png_structp png_ptr, png_bytep data, png_size_t length)
     png_voidp io_ptr = png_get_io_ptr(png_ptr);
     CPPUNIT_ASSERT(io_ptr);
 
+    assert(io_ptr != nullptr);
     std::stringstream& streamTile = *(std::stringstream*)io_ptr;
     streamTile.read((char*)data, length);
 }
@@ -479,6 +480,7 @@ void TileCacheTests::checkBlackTile(std::stringstream& tile)
     }
 
     CPPUNIT_ASSERT_MESSAGE("The tile is 100% black", black != height * width);
+    assert(height * width != 0);
     CPPUNIT_ASSERT_MESSAGE("The tile is 90% black", (black * 100) / (height * width) < 90);
 }
 


More information about the Libreoffice-commits mailing list