From d7b27f24fbbad20de24c7443033972aff00a575a Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Wed, 19 Oct 2005 09:31:35 +0000 Subject: [PATCH] added some object checking - i think we should make sure this object checking is everywhere - if we can. anyone wondering about someothnig to do.. add in the object check macros for any struct thats is an object :) SVN revision: 17678 --- src/bin/e_border.c | 41 +++++++++++++++++++++++++++++++++++++---- src/bin/e_utils.c | 14 ++++++++++++++ src/bin/e_winlist.c | 6 ++++++ src/bin/e_zone.c | 32 +++++++++++++++++++++++++++++++- 4 files changed, 88 insertions(+), 5 deletions(-) diff --git a/src/bin/e_border.c b/src/bin/e_border.c index 4a7fd7d..0350996 100644 --- a/src/bin/e_border.c +++ b/src/bin/e_border.c @@ -669,6 +669,7 @@ void e_border_resize(E_Border *bd, int w, int h) { E_Event_Border_Resize *ev; + E_OBJECT_CHECK(bd); E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); @@ -1683,8 +1684,8 @@ void e_border_iconify(E_Border *bd) { E_Event_Border_Iconify *ev; - unsigned int iconic; + E_OBJECT_CHECK(bd); E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if ((bd->fullscreen) || (bd->shading)) return; @@ -1938,6 +1939,8 @@ e_border_client_list() void e_border_act_move_begin(E_Border *bd, Ecore_X_Event_Mouse_Button_Down *ev) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (bd->lock_user_location) return; if (!bd->moving) { @@ -1960,6 +1963,8 @@ e_border_act_move_begin(E_Border *bd, Ecore_X_Event_Mouse_Button_Down *ev) void e_border_act_move_end(E_Border *bd, Ecore_X_Event_Mouse_Button_Up *ev) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (!bd->moving) return; bd->moving = 0; _e_border_pointer_move_end(bd); @@ -1971,6 +1976,8 @@ e_border_act_move_end(E_Border *bd, Ecore_X_Event_Mouse_Button_Up *ev) void e_border_act_resize_begin(E_Border *bd, Ecore_X_Event_Mouse_Button_Down *ev) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (bd->lock_user_size) return; if (bd->resize_mode == RESIZE_NONE) { @@ -2016,6 +2023,8 @@ e_border_act_resize_begin(E_Border *bd, Ecore_X_Event_Mouse_Button_Down *ev) void e_border_act_resize_end(E_Border *bd, Ecore_X_Event_Mouse_Button_Up *ev) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (bd->resize_mode != RESIZE_NONE) { _e_border_pointer_resize_end(bd); @@ -2029,6 +2038,8 @@ e_border_act_resize_end(E_Border *bd, Ecore_X_Event_Mouse_Button_Up *ev) void e_border_act_menu_begin(E_Border *bd, Ecore_X_Event_Mouse_Button_Down *ev, int key) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (ev) { _e_border_menu_show(bd, @@ -2048,6 +2059,8 @@ e_border_act_menu_begin(E_Border *bd, Ecore_X_Event_Mouse_Button_Down *ev, int k void e_border_act_close_begin(E_Border *bd) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (bd->lock_close) return; if (bd->client.icccm.delete_request) { @@ -2063,6 +2076,8 @@ e_border_act_close_begin(E_Border *bd) void e_border_act_kill_begin(E_Border *bd) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (bd->internal) return; if (bd->lock_close) return; if ((bd->client.netwm.pid > 1) && (e_config->kill_process)) @@ -2083,6 +2098,8 @@ e_border_icon_add(E_Border *bd, Evas *evas) Evas_Object *o; E_App *a = NULL; + E_OBJECT_CHECK_RETURN(bd, NULL); + E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, NULL); if (bd->app) { e_object_unref(E_OBJECT(bd->app)); @@ -2172,6 +2189,8 @@ e_border_lost_windows_get(E_Zone *zone) Evas_List *list = NULL, *l; int loss_overlap = 5; + E_OBJECT_CHECK_RETURN(zone, NULL); + E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, NULL); for (l = borders; l; l = l->next) { E_Border *bd; @@ -2231,8 +2250,9 @@ e_border_lost_windows_get(E_Zone *zone) void e_border_ping(E_Border *bd) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (!e_config->ping_clients) return; - bd->ping_ok = 0; ecore_x_netwm_ping_send(bd->client.win); bd->ping = ecore_time_get(); @@ -2317,18 +2337,21 @@ e_border_immortal_windows_get(void) const char * e_border_name_get(E_Border *bd) { + E_OBJECT_CHECK_RETURN(bd, ""); + E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, ""); if (bd->client.netwm.name) return bd->client.netwm.name; else if (bd->client.icccm.title) return bd->client.icccm.title; - else - return ""; + return ""; } void e_border_signal_move_begin(E_Border *bd, char *sig, char *src) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (!_e_border_move_begin(bd)) return; bd->moving = 1; _e_border_pointer_move_begin(bd); @@ -2339,6 +2362,8 @@ e_border_signal_move_begin(E_Border *bd, char *sig, char *src) void e_border_signal_move_end(E_Border *bd, char *sig, char *src) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (!bd->moving) return; bd->moving = 0; _e_border_pointer_move_end(bd); @@ -2350,6 +2375,8 @@ e_border_signal_move_end(E_Border *bd, char *sig, char *src) int e_border_resizing_get(E_Border *bd) { + E_OBJECT_CHECK_RETURN(bd, 0); + E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, 0); if (bd->resize_mode == RESIZE_NONE) return 0; return 1; } @@ -2360,6 +2387,8 @@ e_border_signal_resize_begin(E_Border *bd, char *dir, char *sig, char *src) Ecore_X_Gravity grav = ECORE_X_GRAVITY_NW; int resize_mode = RESIZE_BR; + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (!_e_border_resize_begin(bd)) return; if (!strcmp(dir, "tl")) @@ -2411,6 +2440,8 @@ e_border_signal_resize_begin(E_Border *bd, char *dir, char *sig, char *src) void e_border_signal_resize_end(E_Border *bd, char *dir, char *sig, char *src) { + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); if (bd->resize_mode == RESIZE_NONE) return; _e_border_resize_handle(bd); _e_border_pointer_resize_end(bd); @@ -2425,6 +2456,8 @@ e_border_resize_limit(E_Border *bd, int *w, int *h) { double a; + E_OBJECT_CHECK(bd); + E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE); *w -= bd->client_inset.l + bd->client_inset.r; *h -= bd->client_inset.t + bd->client_inset.b; if (*h < 1) *h = 1; diff --git a/src/bin/e_utils.c b/src/bin/e_utils.c index fffb71b..c531892 100644 --- a/src/bin/e_utils.c +++ b/src/bin/e_utils.c @@ -37,6 +37,9 @@ e_util_container_fake_mouse_up_later(E_Container *con, int button) { E_Util_Fake_Mouse_Up_Info *info; + E_OBJECT_CHECK(con); + E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE); + info = calloc(1, sizeof(E_Util_Fake_Mouse_Up_Info)); if (info) { @@ -50,6 +53,9 @@ e_util_container_fake_mouse_up_later(E_Container *con, int button) void e_util_container_fake_mouse_up_all_later(E_Container *con) { + E_OBJECT_CHECK(con); + E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE); + e_util_container_fake_mouse_up_later(con, 1); e_util_container_fake_mouse_up_later(con, 2); e_util_container_fake_mouse_up_later(con, 3); @@ -94,6 +100,8 @@ e_util_zone_current_get(E_Manager *man) { E_Container *con; + E_OBJECT_CHECK_RETURN(man, NULL); + E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, NULL); con = e_container_current_get(man); if (con) { @@ -419,6 +427,9 @@ e_util_desk_border_above(E_Border *bd) Evas_List *l; int pos, i; + E_OBJECT_CHECK_RETURN(bd, NULL); + E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, NULL); + if (bd->layer == 0) pos = 0; else if ((bd->layer > 0) && (bd->layer <= 50)) pos = 1; else if ((bd->layer > 50) && (bd->layer <= 100)) pos = 2; @@ -459,6 +470,9 @@ e_util_desk_border_below(E_Border *bd) Evas_List *l; int pos, i; + E_OBJECT_CHECK_RETURN(bd, NULL); + E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, NULL); + if (bd->layer == 0) pos = 0; else if ((bd->layer > 0) && (bd->layer <= 50)) pos = 1; else if ((bd->layer > 50) && (bd->layer <= 100)) pos = 2; diff --git a/src/bin/e_winlist.c b/src/bin/e_winlist.c index 1f56abc..16a6f37 100644 --- a/src/bin/e_winlist.c +++ b/src/bin/e_winlist.c @@ -79,6 +79,9 @@ e_winlist_show(E_Zone *zone) E_Desk *desk; E_Border *bd; + E_OBJECT_CHECK_RETURN(zone, 0); + E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0); + if (winlist) return 0; input_window = ecore_x_window_input_new(zone->container->win, 0, 0, 1, 1); @@ -277,6 +280,7 @@ e_winlist_active_get(void) void e_winlist_next(void) { + if (!winlist) return; if (evas_list_count(wins) == 1) { if (!win_selected) @@ -300,6 +304,7 @@ e_winlist_next(void) void e_winlist_prev(void) { + if (!winlist) return; if (evas_list_count(wins) == 1) { if (!win_selected) @@ -323,6 +328,7 @@ e_winlist_prev(void) void e_winlist_modifiers_set(int mod) { + if (!winlist) return; hold_mod = mod; hold_count = 0; if (hold_mod & ECORE_X_MODIFIER_SHIFT) hold_count++; diff --git a/src/bin/e_zone.c b/src/bin/e_zone.c index f5b5e55..1d47b31 100644 --- a/src/bin/e_zone.c +++ b/src/bin/e_zone.c @@ -208,6 +208,9 @@ e_zone_move_resize(E_Zone *zone, int x, int y, int w, int h) void e_zone_fullscreen_set(E_Zone *zone, int on) { + E_OBJECT_CHECK(zone); + E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE); + if ((!zone->fullscreen) && (on)) { ecore_evas_show(zone->black_ecore_evas); @@ -228,7 +231,7 @@ e_zone_current_get(E_Container *con) E_OBJECT_CHECK_RETURN(con, NULL); E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL); - if (!starting) + if (!starting) { int x, y; @@ -260,6 +263,9 @@ e_zone_bg_reconfigure(E_Zone *zone) void e_zone_flip_coords_handle(E_Zone *zone, int x, int y) { + E_OBJECT_CHECK(zone); + E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE); + if ((y == 0) && E_ZONE_FLIP_UP(zone)) { /* top */ @@ -307,6 +313,9 @@ e_zone_desk_count_set(E_Zone *zone, int x_count, int y_count) E_Event_Zone_Desk_Count_Set *ev; E_Border_List *bl; + E_OBJECT_CHECK(zone); + E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE); + xx = x_count; if (xx < 1) xx = 1; yy = y_count; @@ -403,6 +412,9 @@ e_zone_desk_count_set(E_Zone *zone, int x_count, int y_count) void e_zone_desk_count_get(E_Zone *zone, int *x_count, int *y_count) { + E_OBJECT_CHECK(zone); + E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE); + *x_count = zone->desk_x_count; *y_count = zone->desk_y_count; } @@ -410,6 +422,9 @@ e_zone_desk_count_get(E_Zone *zone, int *x_count, int *y_count) void e_zone_update_flip(E_Zone *zone) { + E_OBJECT_CHECK(zone); + E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE); + _e_zone_update_flip(zone); } @@ -437,6 +452,9 @@ e_zone_update_flip_all(void) void e_zone_desk_flip_by(E_Zone *zone, int dx, int dy) { + E_OBJECT_CHECK(zone); + E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE); + dx = zone->desk_x_current + dx; dy = zone->desk_y_current + dy; e_zone_desk_flip_to(zone, dx, dy); @@ -447,6 +465,9 @@ e_zone_desk_flip_to(E_Zone *zone, int x, int y) { E_Desk *desk; + E_OBJECT_CHECK(zone); + E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE); + if (x < 0) x = 0; else if (x >= zone->desk_x_count) x = zone->desk_x_count - 1; if (y < 0) y = 0; @@ -458,6 +479,9 @@ e_zone_desk_flip_to(E_Zone *zone, int x, int y) void e_zone_desk_linear_flip_by(E_Zone *zone, int dx) { + E_OBJECT_CHECK(zone); + E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE); + dx = zone->desk_x_current + (zone->desk_y_current * zone->desk_x_count) + dx; dx = dx % (zone->desk_x_count * zone->desk_y_count); @@ -471,6 +495,9 @@ e_zone_desk_linear_flip_to(E_Zone *zone, int x) { int y; + E_OBJECT_CHECK(zone); + E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE); + if (x < 0) return; y = x / zone->desk_x_count; x = x - (y * zone->desk_x_count); @@ -539,6 +566,9 @@ e_zone_app_exec(E_Zone *zone, E_App *a) char *penv_ld_preload_path;*/ char buf[4096], buf2[32]; + E_OBJECT_CHECK_RETURN(zone, 0); + E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0); + if (!a) return 0; if (startup_id == 0) { -- 2.7.4