diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-17 16:38:04 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-17 16:00:44 +0000 |
commit | 45c2410041c48c22bd860efb42d4daadad7869b0 (patch) | |
tree | 7adf4d278976bcadd284c8d1cbd6a863f98c14d0 /desktop | |
parent | 9ec54e92407cd632c4e38317f914edd557835a86 (diff) |
LOK: change type of view ids to uintptr_t
This fixes the following problem:
- createView() = 1
- createView() = 2
- destroyView(1)
and then view #2 was renumbered to 1.
Instead expose the pointer address of the SfxViewShell as the ID, which
is not changing in such a situation.
Note that the SfxViewShell <-> ID mapping is an implementation detail of
SfxLokHelper, and only pointers are converted to IDs, user-supplied IDs
are never converted back to pointers.
Change-Id: If79ef8b99ba391011b5d82b219ad13447d44cd5a
Reviewed-on: https://gerrit.libreoffice.org/26423
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 11 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 16 |
2 files changed, 14 insertions, 13 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 3fd66343a424..d341c76247cd 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -295,16 +295,17 @@ void DesktopLOKTest::testCreateView() LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument)); - int nId = pDocument->m_pDocumentClass->createView(pDocument); + std::uintptr_t nId0 = pDocument->m_pDocumentClass->getView(pDocument); + std::uintptr_t nId1 = pDocument->m_pDocumentClass->createView(pDocument); CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViews(pDocument)); // Make sure the created view is the active one, then switch to the old // one. - CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getView(pDocument)); - pDocument->m_pDocumentClass->setView(pDocument, 0); - CPPUNIT_ASSERT_EQUAL(0, pDocument->m_pDocumentClass->getView(pDocument)); + CPPUNIT_ASSERT_EQUAL(nId1, pDocument->m_pDocumentClass->getView(pDocument)); + pDocument->m_pDocumentClass->setView(pDocument, nId0); + CPPUNIT_ASSERT_EQUAL(nId0, pDocument->m_pDocumentClass->getView(pDocument)); - pDocument->m_pDocumentClass->destroyView(pDocument, nId); + pDocument->m_pDocumentClass->destroyView(pDocument, nId1); CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument)); } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index a0aebeed4fe7..c0477a5c34ba 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -364,10 +364,10 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTileTwipWidth, int nTileTwipHeight); static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight); -static int doc_createView(LibreOfficeKitDocument* pThis); -static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId); -static void doc_setView(LibreOfficeKitDocument* pThis, int nId); -static int doc_getView(LibreOfficeKitDocument* pThis); +static uintptr_t doc_createView(LibreOfficeKitDocument* pThis); +static void doc_destroyView(LibreOfficeKitDocument* pThis, uintptr_t nId); +static void doc_setView(LibreOfficeKitDocument* pThis, uintptr_t nId); +static uintptr_t doc_getView(LibreOfficeKitDocument* pThis); static int doc_getViews(LibreOfficeKitDocument* pThis); static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis, const char *pFontName, @@ -1850,28 +1850,28 @@ static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int pDoc->setClientVisibleArea(aRectangle); } -static int doc_createView(LibreOfficeKitDocument* /*pThis*/) +static uintptr_t doc_createView(LibreOfficeKitDocument* /*pThis*/) { SolarMutexGuard aGuard; return SfxLokHelper::createView(); } -static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId) +static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId) { SolarMutexGuard aGuard; SfxLokHelper::destroyView(nId); } -static void doc_setView(LibreOfficeKitDocument* /*pThis*/, int nId) +static void doc_setView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId) { SolarMutexGuard aGuard; SfxLokHelper::setView(nId); } -static int doc_getView(LibreOfficeKitDocument* /*pThis*/) +static uintptr_t doc_getView(LibreOfficeKitDocument* /*pThis*/) { SolarMutexGuard aGuard; |