]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Unity/X11: Free desktop mappings when exiting Unity.
authorVMware, Inc <>
Mon, 20 Dec 2010 21:47:42 +0000 (13:47 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 20 Dec 2010 21:47:42 +0000 (13:47 -0800)
When last hacking this code, I added two ASSERTs making sure that
the host:guest desktop map pointers were NULL when entering Unity
and numDesktops == 0.  This is true when first entering Unity
in a single session, but not for subsequent entrances in the same
session.

Rather than keep the mappings until the plugin is destroyed, we'll
now flush them upon exit.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/unity/unitylib/unityPlatformX11.cc

index 537d978b59bf61ac763498357f45c447faa2dd5a..62d29482f23b8da4ac8dcfd2011ce3b6d6e9d60b 100644 (file)
@@ -348,10 +348,6 @@ UnityPlatformCleanup(UnityPlatform *up) // IN
       up->display = NULL;
    }
 
-   free(up->desktopInfo.guestDesktopToUnity);
-   up->desktopInfo.guestDesktopToUnity = NULL;
-   free(up->desktopInfo.unityDesktopToGuest);
-   up->desktopInfo.unityDesktopToGuest = NULL;
    up->desktopWindow = NULL;
 
    free(up);
@@ -796,6 +792,11 @@ UnityPlatformExitUnity(UnityPlatform *up) // IN
    UnityX11EventTeardownSource(up);
 
    up->desktopInfo.numDesktops = 0; // Zero means host has not set virtual desktop config
+   free(up->desktopInfo.guestDesktopToUnity);
+   up->desktopInfo.guestDesktopToUnity = NULL;
+   free(up->desktopInfo.unityDesktopToGuest);
+   up->desktopInfo.unityDesktopToGuest = NULL;
+
    UnityX11RestoreSystemSettings(up);
 
    HashTable_ToArray(up->allWindows,
@@ -968,14 +969,13 @@ UnityPlatformEnterUnity(UnityPlatform *up) // IN
          Warning("%s: _NET_NUMBER_OF_DESKTOPS set to 0; impossible.\n", __FUNCTION__);
          return FALSE;
       }
+
       up->desktopInfo.guestDesktopToUnity = (UnityDesktopId*)
-         Util_SafeRealloc(up->desktopInfo.guestDesktopToUnity,
-                          up->desktopInfo.numDesktops
-                          * sizeof up->desktopInfo.guestDesktopToUnity[0]);
+         Util_SafeMalloc(up->desktopInfo.numDesktops *
+                         sizeof up->desktopInfo.guestDesktopToUnity[0]);
       up->desktopInfo.unityDesktopToGuest = (uint32*)
-         Util_SafeRealloc(up->desktopInfo.unityDesktopToGuest,
-                          up->desktopInfo.numDesktops
-                          * sizeof up->desktopInfo.unityDesktopToGuest[0]);
+         Util_SafeMalloc(up->desktopInfo.numDesktops *
+                         sizeof up->desktopInfo.unityDesktopToGuest[0]);
 
       for (i = 0; i < up->desktopInfo.numDesktops; i++) {
          up->desktopInfo.guestDesktopToUnity[i] =