summaryrefslogtreecommitdiff
path: root/ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp')
-rw-r--r--ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp b/ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp
index ade58f0..edcbaff 100644
--- a/ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp
+++ b/ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp
@@ -64,6 +64,7 @@ WLContext::~WLContext()
* The following correspondences between file names and cursors was copied
* from: https://bugs.kde.org/attachment.cgi?id=67313
*/
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
static const char *left_ptrs[] = {
"left_ptr",
@@ -84,14 +85,13 @@ create_cursors(WLContext* wlContext)
fprintf(stderr, "could not load default theme\n");
return;
}
- wlContext->SetWLCursor((wl_cursor*) malloc(sizeof(wl_cursor)));
- for (j = 0; !cursor && j < 4; ++j)
+ for (j = 0; !cursor && j < ARRAY_SIZE(left_ptrs); ++j)
cursor = wl_cursor_theme_get_cursor(wlContext->GetWLCursorTheme(),
left_ptrs[j]);
if (!cursor)
- fprintf(stderr, "could not load cursor '%s'\n", left_ptrs[j]);
+ fprintf(stderr, "could not load any cursor\n");
wlContext->SetWLCursor(cursor);
}
@@ -170,11 +170,10 @@ WLContext::SeatHandleCapabilities(void* data, struct wl_seat* seat, uint32_t cap
context->ctx->SetPointerSurface(NULL);
}
- if (context->ctx->GetWLCursorTheme())
+ if (context->ctx->GetWLCursorTheme()){
wl_cursor_theme_destroy(context->ctx->GetWLCursorTheme());
-
- if (context->ctx->GetWLCursor())
- free(context->ctx->GetWLCursor());
+ context->ctx->SetWLCursor(NULL);
+ }
}
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !context->wlKeyboard){
@@ -235,11 +234,11 @@ WLContext::DestroyWLContext()
m_pointerSurface = NULL;
}
- if (m_wlCursorTheme)
+ if (m_wlCursorTheme){
wl_cursor_theme_destroy(m_wlCursorTheme);
-
- if (m_wlCursor)
- free(m_wlCursor);
+ m_wlCursorTheme = NULL;
+ m_wlCursor = NULL;
+ }
wl_registry_destroy(m_wlRegistry);
wl_display_flush(m_wlDisplay);