forked from enlightenment/efl
elm_code: better safety around widget edge cases
Fixes crashes when dragging selection out of widget. @fix
This commit is contained in:
parent
5da4c96087
commit
650606ab90
|
@ -10,7 +10,11 @@ EAPI const char *
|
||||||
elm_code_line_text_get(Elm_Code_Line *line, unsigned int *length)
|
elm_code_line_text_get(Elm_Code_Line *line, unsigned int *length)
|
||||||
{
|
{
|
||||||
if (!line)
|
if (!line)
|
||||||
return NULL;
|
{
|
||||||
|
if (length)
|
||||||
|
*length = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (length)
|
if (length)
|
||||||
*length = line->length;
|
*length = line->length;
|
||||||
|
|
|
@ -653,8 +653,8 @@ _elm_code_widget_position_at_coordinates_get(Eo *obj, Elm_Code_Widget_Data *pd,
|
||||||
Elm_Code_Line *line;
|
Elm_Code_Line *line;
|
||||||
Evas_Coord ox = 0, oy = 0, sx = 0, sy = 0, rowy = 0;
|
Evas_Coord ox = 0, oy = 0, sx = 0, sy = 0, rowy = 0;
|
||||||
Evas_Object *grid;
|
Evas_Object *grid;
|
||||||
int cw = 0, ch = 0, gutter;
|
int cw = 0, ch = 0, gutter, retcol;
|
||||||
unsigned int guess = 0, number;
|
unsigned int guess = 1, number;
|
||||||
|
|
||||||
widget = (Elm_Code_Widget *)obj;
|
widget = (Elm_Code_Widget *)obj;
|
||||||
evas_object_geometry_get(widget, &ox, &oy, NULL, NULL);
|
evas_object_geometry_get(widget, &ox, &oy, NULL, NULL);
|
||||||
|
@ -665,7 +665,7 @@ _elm_code_widget_position_at_coordinates_get(Eo *obj, Elm_Code_Widget_Data *pd,
|
||||||
_elm_code_widget_cell_size_get(widget, &cw, &ch);
|
_elm_code_widget_cell_size_get(widget, &cw, &ch);
|
||||||
gutter = elm_obj_code_widget_text_left_gutter_width_get(widget);
|
gutter = elm_obj_code_widget_text_left_gutter_width_get(widget);
|
||||||
|
|
||||||
if (ch > 0)
|
if (y >= 0 && ch > 0)
|
||||||
guess = ((double) y / ch) + 1;
|
guess = ((double) y / ch) + 1;
|
||||||
number = guess;
|
number = guess;
|
||||||
|
|
||||||
|
@ -684,10 +684,11 @@ _elm_code_widget_position_at_coordinates_get(Eo *obj, Elm_Code_Widget_Data *pd,
|
||||||
|
|
||||||
if (col)
|
if (col)
|
||||||
{
|
{
|
||||||
if (cw == 0)
|
retcol = ((double) x / cw) - gutter + 1;
|
||||||
*col = 0;
|
if (retcol <= 0 || cw == 0)
|
||||||
|
*col = 1;
|
||||||
else
|
else
|
||||||
*col = ((double) x / cw) - gutter + 1;
|
*col = retcol;
|
||||||
}
|
}
|
||||||
if (row)
|
if (row)
|
||||||
*row = number;
|
*row = number;
|
||||||
|
|
Loading…
Reference in New Issue