[X2Go-Commits] [x2gokdriveclient] 01/01: reiniting of frame and cursors caches if cache is corrupted.

git-admin at x2go.org git-admin at x2go.org
Thu Sep 16 09:54:02 CEST 2021


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2gokdriveclient.

commit 4482061eea6ede88b57d144af536aaa772b01bbb
Author: Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
Date:   Thu Sep 16 09:53:16 2021 +0200

    reiniting of frame and cursors caches if cache is corrupted.
---
 client.cpp       | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 client.h         |  7 ++++++-
 debian/changelog |  1 +
 3 files changed, 62 insertions(+), 7 deletions(-)

diff --git a/client.cpp b/client.cpp
index 8b0d1d2..f04d4ac 100644
--- a/client.cpp
+++ b/client.cpp
@@ -669,7 +669,10 @@ QPixmap Client::getPixmapFromCache(uint32_t crc)
     if(!frameCache.contains(crc))
     {
         qDebug()<<"GETPIXMAP: frame"<<hex<<crc<<"not found in cache";
-        exitOnError(tr("Frame not found in cache"));
+        if(serverVersion<5)
+            exitOnError(tr("Frame not found in cache"));
+        else
+            requestCacheRebuild();
         return QPixmap();
     }
     return frameCache[crc];
@@ -710,7 +713,10 @@ void Client::renderFrame()
                     if(!frameCache.contains(reg->source_crc))
                     {
                         qDebug()<<"region"<<hex<<reg->source_crc<<"not found in cache";
-                        exitOnError(tr("region not found in cache"));
+                        if(serverVersion<5)
+                            exitOnError(tr("region not found in cache"));
+                        else
+                            requestCacheRebuild();
                         return;
                     }
                     //qDebug()<<"REG:"<<reg->x<<reg->y<<reg->width<< reg->height<<"SOURCE:"<<reg->source_x<<reg->source_y;
@@ -843,7 +849,10 @@ void Client::getCursor()
         if(!cursorCache.contains(currentCursor->serialNumber))
         {
             qDebug()<<"cursor not found:"<<currentCursor->serialNumber;
-            exitOnError(tr("Cursor not found in cache"));
+            if(serverVersion<5)
+                exitOnError(tr("Cursor not found in cache"));
+            else
+                requestCacheRebuild();
             return;
         }
         displayArea->setCursor(*cursorCache[currentCursor->serialNumber]);
@@ -961,7 +970,10 @@ void Client::getDeletedCursorsList()
         if(!cursorCache.contains(serial))
         {
             qDebug()<<"cursor not found in cache: "<<serial;
-            exitOnError(tr("cursor not found in cache"));
+            if(serverVersion<5)
+                exitOnError(tr("cursor not found in cache"));
+            else
+                requestCacheRebuild();
             return;
         }
         delete cursorCache[serial];
@@ -981,7 +993,10 @@ void Client::getDeletedFramesList()
         if(!frameCache.contains(crc))
         {
             qDebug()<<"DELETING: frame not found in cache: "<<hex<<crc;
-            exitOnError(tr("frame not found in cache"));
+            if(serverVersion<5)
+                exitOnError(tr("frame not found in cache"));
+            else
+                requestCacheRebuild();
             return;
         }
 //         qDebug()<<"deleting frame from cache with crc"<<hex<<crc;
@@ -1097,7 +1112,10 @@ void Client::getRegionImage()
         fl.write((const char*)messageBuffer, currentFrame->regions.last()->dataSize);
         fl.close();
         exit(-1);*/
-        exitOnError("Image loading failed");
+        if(serverVersion<5)
+            exitOnError("Image loading failed");
+        else
+            requestCacheRebuild();
     }
     if(currentFrame->numOfRegions == (uint)currentFrame->regions.size())
     {
@@ -1196,6 +1214,11 @@ void Client::readDataHeader()
             getClientSelection();
             break;
         }
+        case REINIT:
+        {
+            reinitCaches();
+            break;
+        }
         default:
         {
             qDebug()<<"Unsupported header type: "<<data_type;
@@ -1804,3 +1827,29 @@ int Client::max_chunk()
     }
     return 10*1024*1024/4; //10MB
 }
+
+void Client::requestCacheRebuild()
+{
+    //sending the feature vesrion and OS version to the server
+    char evmsg[EVLENGTH]{};
+    uint32_t etype;
+    etype=CACHEREBUILD;
+    memcpy(evmsg,(char*)&etype,4);
+    qDebug()<<"Requesting cache rebuild";
+    sendEvent(evmsg);
+}
+
+void Client::reinitCaches()
+{
+    qDebug()<<"Clearing all caches";
+    cursorCache.clear();
+    frameCache.clear();
+    wantRepaint=false;
+    if(currentFrame)
+        delete currentFrame;
+    if(currentCursor)
+        delete currentCursor;
+    currentFrame=0;
+    currentCursor=0;
+    displayArea->repaint(0, 0, displayArea->width(), displayArea->height());
+}
diff --git a/client.h b/client.h
index 874d0e4..5adf87d 100644
--- a/client.h
+++ b/client.h
@@ -59,6 +59,9 @@ enum OS_VERSION{OS_LINUX, OS_WINDOWS, OS_DARWIN};
 #define SELECTIONEVENT 9
 #define CLIENTVERSION 10
 #define DEMANDSELECTION 11
+//This event only sent by web client at the moment
+#define KEEPALIVE 12
+#define CACHEREBUILD 13
 
 #define ShiftMask (1<<0)
 #define LockMask (1<<1)
@@ -201,13 +204,14 @@ private slots:
     void slotEnableRandr();
     void slotResizeFSFinal();
     void slotSelectionChanged(QClipboard::Mode mode);
+    void requestCacheRebuild();
 public slots:
     void editWindowTitle();
 
 
 private:
     enum{ HEADER, FRAMEREGION, REGIONDATA ,CURSORDATA, CURSORLIST, FRAMELIST, SELECTIONBUFFER } currentDataType;
-    enum HeaderType{ FRAME, DELETEDFRAMES, CURSOR, DELETEDCURSORS, SELECTION, SERVER_VERSION, DEMANDCLIENTSELECTION};
+    enum HeaderType{ FRAME, DELETEDFRAMES, CURSOR, DELETEDCURSORS, SELECTION, SERVER_VERSION, DEMANDCLIENTSELECTION,REINIT};
 
     void getServerversion();
     void getClientSelection();
@@ -230,6 +234,7 @@ private:
     void setCursor();
     void sendGeometryEvent();
     void setFS(int screenNumber);
+    void reinitCaches();
     bool wantRepaint=false;
 #ifndef Q_OS_LINUX
     void sendSelectionToServer(SelectionType selection);
diff --git a/debian/changelog b/debian/changelog
index 183140b..ad8c176 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -31,5 +31,6 @@ x2gokdriveclient (0.0.0.1-0x2go1) UNRELEASED; urgency=medium
     - support sending and recieving selections on demand. Support reading and writing INCR properties.
     - include xcb/xproto.h header
     - use zlib library to decompress compressed strings instead of built in QT function.
+    - reiniting of frame and cursors caches if cache is corrupted.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Tue, 04 Jun 2019 11:10:43 +0200

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gokdriveclient.git


More information about the x2go-commits mailing list