Blob Blame History Raw
From 54cbf52419e6318c2cdf19232f79a515ffb6e7f6 Mon Sep 17 00:00:00 2001
From: Pranav Kant <pranavk@gnome.org>
Date: Thu, 24 Sep 2015 18:47:01 +0200
Subject: [PATCH 166/398] lokdocview: Reset view completely

Resetting tiles only is not enough. We need to empty stale
selection rectangles, handle bars, cursor positions etc., so that
they do not interfere with next view to be opened using same
widget instance.

We are not destroying the document here, so the widget would
still point to the same document unless it is made to point to
another document by subsequent lok_doc_view_open_document calls.

Change-Id: I3c7cc789c8c7393b3793b4edf6aa96d54bc0b1a3
Reviewed-on: https://gerrit.libreoffice.org/18866
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
(cherry picked from commit c3ce35f0a12af2887b10987f76675174563487d7)
---
 libreofficekit/source/gtk/lokdocview.cxx | 37 ++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 6679cee56cd3..99476764e69d 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1986,6 +1986,43 @@ lok_doc_view_reset_view(LOKDocView* pDocView)
 {
     LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
     priv->m_aTileBuffer.resetAllTiles();
+    priv->m_nLoadProgress = 0.0;
+
+    memset(&priv->m_aVisibleCursor, 0, sizeof(priv->m_aVisibleCursor));
+    priv->m_bCursorOverlayVisible = false;
+    priv->m_bCursorVisible = false;
+
+    priv->m_nLastButtonPressTime = 0;
+    priv->m_nLastButtonReleaseTime = 0;
+    priv->m_aTextSelectionRectangles.clear();
+
+    memset(&priv->m_aTextSelectionStart, 0, sizeof(priv->m_aTextSelectionStart));
+    memset(&priv->m_aTextSelectionEnd, 0, sizeof(priv->m_aTextSelectionEnd));
+    memset(&priv->m_aGraphicSelection, 0, sizeof(priv->m_aGraphicSelection));
+    priv->m_bInDragGraphicSelection = false;
+
+    cairo_surface_destroy(priv->m_pHandleStart);
+    priv->m_pHandleStart = 0;
+    memset(&priv->m_aHandleStartRect, 0, sizeof(priv->m_aHandleStartRect));
+    priv->m_bInDragStartHandle = false;
+
+    cairo_surface_destroy(priv->m_pHandleMiddle);
+    priv->m_pHandleMiddle = 0;
+    memset(&priv->m_aHandleMiddleRect, 0, sizeof(priv->m_aHandleMiddleRect));
+    priv->m_bInDragMiddleHandle = false;
+
+    cairo_surface_destroy(priv->m_pHandleEnd);
+    priv->m_pHandleEnd = 0;
+    memset(&priv->m_aHandleEndRect, 0, sizeof(priv->m_aHandleEndRect));
+    priv->m_bInDragEndHandle = false;
+
+    cairo_surface_destroy(priv->m_pGraphicHandle);
+    priv->m_pGraphicHandle = 0;
+    memset(&priv->m_aGraphicHandleRects, 0, sizeof(priv->m_aGraphicHandleRects));
+    memset(&priv->m_bInDragGraphicHandles, 0, sizeof(priv->m_bInDragGraphicHandles));
+
+    priv->m_nViewId = 0;
+
     gtk_widget_queue_draw(GTK_WIDGET(pDocView));
 }
 
-- 
2.12.0