]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix KDE file copy and paste.
authorVMware, Inc <>
Thu, 24 Feb 2011 22:57:13 +0000 (14:57 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 24 Feb 2011 22:57:13 +0000 (14:57 -0800)
There were a couple of bugs in how we respond to paste requests.
First, we can be called multiple times. So we needed a guard to
check if we are already in the process of transferring files.

Second, we should never clear the selection data unless we see an
error or fail case of some kind. While it does not affect GNOME
environment, looks like KDE can get really confused by this (the
symptom is a prompt for path name which has been reported often
in bugs over the past year I have been involved with DnD.)

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp

index e45d72c5218475b9d7a2e2fe1209bdbc382cdd4a..97fbe95c0d0a8fb3d8b6b654bea4665790715793 100644 (file)
@@ -306,9 +306,6 @@ CopyPasteUIX11::LocalGetFileRequestCB(Gtk::SelectionData& sd,        // IN:
 {
    g_debug("%s: enter.\n", __FUNCTION__);
    VmTimeType curTime;
-   mBlockAdded = false;
-
-   sd.set(sd.get_target().c_str(), "");
 
    curTime = GetCurrentTime();
 
@@ -326,12 +323,25 @@ CopyPasteUIX11::LocalGetFileRequestCB(Gtk::SelectionData& sd,        // IN:
    if (!mCP->IsCopyPasteAllowed()) {
       g_debug("%s: copy paste is not allowed, returning.\n",
             __FUNCTION__);
+      sd.set(sd.get_target().c_str(), "");
       return;
    }
 
    g_debug("%s: Got paste request, target is %s\n", __FUNCTION__,
          sd.get_target().c_str());
 
+   if (mHGGetFilesInitiated) {
+      /*
+       * On KDE (at least), we can see this multiple times, so ignore if
+       * we are already getting files.
+       */
+      g_debug("%s: already processing a GetFile request, returning.\n",
+              __FUNCTION__);
+      sd.set(sd.get_target().c_str(), mHGCopiedUriList.c_str());
+      return;
+   }
+
+
    /* Copy the files. */
    if (!mHGGetFilesInitiated) {
       utf::string str;
@@ -348,10 +358,12 @@ CopyPasteUIX11::LocalGetFileRequestCB(Gtk::SelectionData& sd,        // IN:
 
       if (0 == hgStagingDir.bytes()) {
          g_debug("%s: Can not create staging directory\n", __FUNCTION__);
+         sd.set(sd.get_target().c_str(), "");
          return;
       }
       mHGGetFilesInitiated = true;
 
+      mBlockAdded = false;
       if (DnD_BlockIsReady(mBlockCtrl) && mBlockCtrl->AddBlock(mBlockCtrl->fd, hgStagingDir.c_str())) {
          g_debug("%s: add block for %s.\n",
                __FUNCTION__, hgStagingDir.c_str());
@@ -374,6 +386,7 @@ CopyPasteUIX11::LocalGetFileRequestCB(Gtk::SelectionData& sd,        // IN:
       } else {
          g_debug("%s: Unknown request target: %s\n", __FUNCTION__,
                sd.get_target().c_str());
+         sd.set(sd.get_target().c_str(), "");
          return;
       }
 
@@ -381,6 +394,7 @@ CopyPasteUIX11::LocalGetFileRequestCB(Gtk::SelectionData& sd,        // IN:
       stagingDirName = GetLastDirName(hgStagingDir);
       if (0 == stagingDirName.bytes()) {
          g_debug("%s: Can not get staging directory name\n", __FUNCTION__);
+         sd.set(sd.get_target().c_str(), "");
          return;
       }
 
@@ -403,6 +417,7 @@ CopyPasteUIX11::LocalGetFileRequestCB(Gtk::SelectionData& sd,        // IN:
 
    if (0 == mHGCopiedUriList.bytes()) {
       g_debug("%s: Can not get uri list\n", __FUNCTION__);
+      sd.set(sd.get_target().c_str(), "");
       return;
    }
 
@@ -436,6 +451,7 @@ CopyPasteUIX11::LocalGetFileRequestCB(Gtk::SelectionData& sd,        // IN:
          if (select(0, NULL, NULL, NULL, &tv) == -1) {
             g_debug("%s: error in select (%s).\n", __FUNCTION__,
                   strerror(errno));
+            sd.set(sd.get_target().c_str(), "");
             return;
          }
       }