From 609ae4f2ea7789f0a34077f4cc5567fae564f6b3 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Wed, 8 Dec 2010 07:57:20 +0100
Subject: [PATCH] bineditor: add a facility to invalidate the cache from the
 outside

This is necessary to handle "live updates". Originally done by ck.
---
 src/plugins/bineditor/bineditor.cpp | 10 +++++++++-
 src/plugins/bineditor/bineditor.h   |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp
index 23b5d04ffbd..ae3945db81e 100644
--- a/src/plugins/bineditor/bineditor.cpp
+++ b/src/plugins/bineditor/bineditor.cpp
@@ -1264,7 +1264,10 @@ void BinEditor::changeData(int position, uchar character, bool highNibble)
     cmd.character = (uchar) dataAt(position);
     cmd.highNibble = highNibble;
 
-    if (!highNibble && !m_undoStack.isEmpty() && m_undoStack.top().position == position && m_undoStack.top().highNibble) {
+    if (!highNibble
+            && !m_undoStack.isEmpty()
+            && m_undoStack.top().position == position
+            && m_undoStack.top().highNibble) {
         // compress
         cmd.character = m_undoStack.top().character;
         m_undoStack.pop();
@@ -1400,6 +1403,11 @@ void BinEditor::setNewWindowRequestAllowed()
     m_canRequestNewWindow = true;
 }
 
+void BinEditor::updateContents()
+{
+    setLazyData(baseAddress() + cursorPosition(), dataSize(), m_blockSize);
+}
+
 QPoint BinEditor::offsetToPos(int offset)
 {
     const int x = m_labelWidth + (offset % 16) * m_columnWidth;
diff --git a/src/plugins/bineditor/bineditor.h b/src/plugins/bineditor/bineditor.h
index 70241a7e63b..aca4a71492f 100644
--- a/src/plugins/bineditor/bineditor.h
+++ b/src/plugins/bineditor/bineditor.h
@@ -73,6 +73,7 @@ public:
     inline int lazyDataBlockSize() const { return m_blockSize; }
     Q_INVOKABLE void addLazyData(quint64 block, const QByteArray &data);
     Q_INVOKABLE void setNewWindowRequestAllowed();
+    Q_INVOKABLE void updateContents();
     bool save(const QString &oldFileName, const QString &newFileName);
 
     void zoomIn(int range = 1);
-- 
GitLab