From: VMware, Inc <> Date: Mon, 20 Dec 2010 21:47:42 +0000 (-0800) Subject: Unity/X11: Free desktop mappings when exiting Unity. X-Git-Tag: 2010.12.19-339835~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d07a82d3925e2c9540fe07368a611fdd07d1bd03;p=thirdparty%2Fopen-vm-tools.git Unity/X11: Free desktop mappings when exiting Unity. 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 --- diff --git a/open-vm-tools/services/plugins/unity/unitylib/unityPlatformX11.cc b/open-vm-tools/services/plugins/unity/unitylib/unityPlatformX11.cc index 537d978b5..62d29482f 100644 --- a/open-vm-tools/services/plugins/unity/unitylib/unityPlatformX11.cc +++ b/open-vm-tools/services/plugins/unity/unitylib/unityPlatformX11.cc @@ -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] =