summaryrefslogtreecommitdiff
path: root/src/lib/ecore_win32
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2020-03-24 14:05:19 +0000
committerStefan Schmidt <s.schmidt@samsung.com>2020-04-03 10:02:02 +0200
commitdc1454f8cf2ba2808caed6f7d8ab64252be26b2e (patch)
treef0297d83a0f362ee59ccf2e2f99db4dc8b29ce22 /src/lib/ecore_win32
parentb1cc09a86c2ff949e07f6bc7ab1f68160b8d9c6d (diff)
free memory in clipboard notify event and fix clipboard clear event
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D11564
Diffstat (limited to 'src/lib/ecore_win32')
-rw-r--r--src/lib/ecore_win32/ecore_win32_event.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/lib/ecore_win32/ecore_win32_event.c b/src/lib/ecore_win32/ecore_win32_event.c
index 28a5b1f07e..6ef8a6cf76 100644
--- a/src/lib/ecore_win32/ecore_win32_event.c
+++ b/src/lib/ecore_win32/ecore_win32_event.c
@@ -1953,6 +1953,18 @@ _ecore_win32_event_handle_delete_request(Ecore_Win32_Callback_Data *msg)
1953 ecore_event_add(ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL); 1953 ecore_event_add(ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
1954} 1954}
1955 1955
1956static void
1957_ecore_win32_event_free_selection_notify(void *data EINA_UNUSED, void *ev)
1958{
1959 Ecore_Win32_Event_Selection_Notify *e;
1960
1961 e = (Ecore_Win32_Event_Selection_Notify *)ev;
1962 if (e->data) free(e->data);
1963 if (e->selection) free(e->selection);
1964 free(e);
1965}
1966
1967
1956void 1968void
1957_ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg) 1969_ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
1958{ 1970{
@@ -1973,12 +1985,9 @@ _ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
1973 */ 1985 */
1974 if (!_ecore_win32_clipboard_has_data) 1986 if (!_ecore_win32_clipboard_has_data)
1975 { 1987 {
1976 /* if case someone else is owning the clipboard, we can't do anything */ 1988 /* in case someone else is owning the clipboard, we can't do anything */
1977 if (!OpenClipboard(msg->window)) 1989 if (!OpenClipboard(msg->window))
1978 { 1990 goto free_e;
1979 free(e);
1980 return;
1981 }
1982 1991
1983 if (IsClipboardFormatAvailable(CF_UNICODETEXT)) 1992 if (IsClipboardFormatAvailable(CF_UNICODETEXT))
1984 { 1993 {
@@ -1997,7 +2006,10 @@ _ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
1997 GlobalUnlock(global); 2006 GlobalUnlock(global);
1998 if (e->data) 2007 if (e->data)
1999 { 2008 {
2000 ecore_event_add(ECORE_WIN32_EVENT_SELECTION_NOTIFY, e, NULL, NULL); 2009 ecore_event_add(ECORE_WIN32_EVENT_SELECTION_NOTIFY,
2010 e,
2011 _ecore_win32_event_free_selection_notify,
2012 NULL);
2001 _ecore_win32_clipboard_has_data = EINA_TRUE; 2013 _ecore_win32_clipboard_has_data = EINA_TRUE;
2002 CloseClipboard(); 2014 CloseClipboard();
2003 return; 2015 return;
@@ -2032,9 +2044,6 @@ _ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
2032 } 2044 }
2033 } 2045 }
2034 } 2046 }
2035 free(e->data);
2036 free(e->selection);
2037 free(e);
2038 CloseClipboard(); 2047 CloseClipboard();
2039 } 2048 }
2040 /* 2049 /*
@@ -2046,15 +2055,14 @@ _ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
2046 if (!IsClipboardFormatAvailable(CF_UNICODETEXT) && 2055 if (!IsClipboardFormatAvailable(CF_UNICODETEXT) &&
2047 !IsClipboardFormatAvailable(CF_TEXT)) 2056 !IsClipboardFormatAvailable(CF_TEXT))
2048 { 2057 {
2049 e->selection = strdup("text/plain;charset=utf-8"); 2058 ecore_event_add(ECORE_WIN32_EVENT_SELECTION_CLEAR, e, NULL, NULL);
2050 if (e->selection) 2059 _ecore_win32_clipboard_has_data = EINA_FALSE;
2051 { 2060 return;
2052 ecore_event_add(ECORE_WIN32_EVENT_SELECTION_CLEAR, e, NULL, NULL);
2053 _ecore_win32_clipboard_has_data = EINA_FALSE;
2054 return;
2055 }
2056 } 2061 }
2057 } 2062 }
2058 2063
2064 free_e:
2065 if (e->data) free(e->data);
2066 if (e->selection) free(e->selection);
2059 free(e); 2067 free(e);
2060} 2068}