<commit_before>#include <Elementary.h>
#include "elm_priv.h"
#include "elm_widget_layout.h"

EAPI const char ELM_LAYOUT_SMART_NAME[] = "elm_layout";

static const char SIG_THEME_CHANGED[] = "theme,changed";

/* no *direct* instantiation of this class, so far */
__UNUSED__ static Evas_Smart *_elm_layout_smart_class_new(void);

/* smart callbacks coming from elm layout objects: */
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
   {SIG_THEME_CHANGED, ""},
   {NULL, NULL}
};

/* these are data operated by layout's class functions internally, and
 * should not be messed up by inhering classes */
typedef struct _Elm_Layout_Sub_Object_Data   Elm_Layout_Sub_Object_Data;
typedef struct _Elm_Layout_Sub_Object_Cursor Elm_Layout_Sub_Object_Cursor;

struct _Elm_Layout_Sub_Object_Data
{
   const char  *part;
   Evas_Object *obj;

   enum {
      SWALLOW,
      BOX_APPEND,
      BOX_PREPEND,
      BOX_INSERT_BEFORE,
      BOX_INSERT_AT,
      TABLE_PACK,
      TEXT
   } type;

   union {
      union {
         const Evas_Object *reference;
         unsigned int       pos;
      } box;
      struct
      {
         unsigned short col, row, colspan, rowspan;
      } table;
      struct
      {
         const char *text;
      } text;
   } p;
};

struct _Elm_Layout_Sub_Object_Cursor
{
   Evas_Object *obj;
   const char  *part;
   const char  *cursor;
   const char  *style;

   Eina_Bool    engine_only : 1;
};

/* layout's sizing evaluation is deferred. evaluation requests are
 * queued up and only flag the object as 'changed'. when it comes to
 * Evas's rendering phase, it will be addressed, finally (see
 * _elm_layout_smart_calculate()). */
static void
_elm_layout_smart_sizing_eval(Evas_Object *obj)
{
   ELM_LAYOUT_DATA_GET(obj, sd);

   if (sd->needs_size_calc) return;
   sd->needs_size_calc = EINA_TRUE;

   evas_object_smart_changed(obj);
}

static void
_on_sub_object_size_hint_change(void *data,
                                Evas *e __UNUSED__,
                                Evas_Object *obj __UNUSED__,
                                void *event_info __UNUSED__)
{
   ELM_LAYOUT_DATA_GET(data, sd);
   if (ELM_WIDGET_DATA(sd)->frozen) return;
   ELM_LAYOUT_CLASS(ELM_WIDGET_DATA(sd)->api)->sizing_eval(data);
}

static void
_part_cursor_free(Elm_Layout_Sub_Object_Cursor *pc)
{
   eina_stringshare_del(pc->part);
   eina_stringshare_del(pc->style);
   eina_stringshare_del(pc->cursor);

   free(pc);
}

/* Elementary smart class for all widgets having an Edje layout as a
 * building block */
EVAS_SMART_SUBCLASS_NEW
  (ELM_LAYOUT_SMART_NAME, _elm_layout, Elm_Layout_Smart_Class,
  Elm_Container_Smart_Class, elm_container_smart_class_get, _smart_callbacks);

EAPI const Elm_Layout_Smart_Class *
elm_layout_smart_class_get(void)
{
   static Elm_Layout_Smart_Class _sc =<commit_msg>Elm layout: Fix segfault in some cases.<commit_after>#include <Elementary.h>
#include "elm_priv.h"
#include "elm_widget_layout.h"

EAPI const char ELM_LAYOUT_SMART_NAME[] = "elm_layout";

static const char SIG_THEME_CHANGED[] = "theme,changed";

/* no *direct* instantiation of this class, so far */
__UNUSED__ static Evas_Smart *_elm_layout_smart_class_new(void);

/* smart callbacks coming from elm layout objects: */
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
   {SIG_THEME_CHANGED, ""},
   {NULL, NULL}
};

/* these are data operated by layout's class functions internally, and
 * should not be messed up by inhering classes */
typedef struct _Elm_Layout_Sub_Object_Data   Elm_Layout_Sub_Object_Data;
typedef struct _Elm_Layout_Sub_Object_Cursor Elm_Layout_Sub_Object_Cursor;

struct _Elm_Layout_Sub_Object_Data
{
   const char  *part;
   Evas_Object *obj;

   enum {
      SWALLOW,
      BOX_APPEND,
      BOX_PREPEND,
      BOX_INSERT_BEFORE,
      BOX_INSERT_AT,
      TABLE_PACK,
      TEXT
   } type;

   union {
      union {
         const Evas_Object *reference;
         unsigned int       pos;
      } box;
      struct
      {
         unsigned short col, row, colspan, rowspan;
      } table;
      struct
      {
         const char *text;
      } text;
   } p;
};

struct _Elm_Layout_Sub_Object_Cursor
{
   Evas_Object *obj;
   const char  *part;
   const char  *cursor;
   const char  *style;

   Eina_Bool    engine_only : 1;
};

/* layout's sizing evaluation is deferred. evaluation requests are
 * queued up and only flag the object as 'changed'. when it comes to
 * Evas's rendering phase, it will be addressed, finally (see
 * _elm_layout_smart_calculate()). */
static void
_elm_layout_smart_sizing_eval(Evas_Object *obj)
{
   ELM_LAYOUT_DATA_GET(obj, sd);

   if (!sd || sd->needs_size_calc) return;
   sd->needs_size_calc = EINA_TRUE;

   evas_object_smart_changed(obj);
}

static void
_on_sub_object_size_hint_change(void *data,
                                Evas *e __UNUSED__,
                                Evas_Object *obj __UNUSED__,
                                void *event_info __UNUSED__)
{
   ELM_LAYOUT_DATA_GET(data, sd);
   if (!sd || ELM_WIDGET_DATA(sd)->frozen) return;
   ELM_LAYOUT_CLASS(ELM_WIDGET_DATA(sd)->api)->sizing_eval(data);
}

static void
_part_cursor_free(Elm_Layout_Sub_Object_Cursor *pc)
{
   eina_stringshare_del(pc->part);
   eina_stringshare_del(pc->style);
   eina_stringshare_del(pc->cursor);

   free(pc);
}

/* Elementary smart class for all widgets having an Edje layout as a
 * building block */
EVAS_SMART_SUBCLASS_NEW
  (ELM_LAYOUT_SMART_NAME, _elm_layout, Elm_Layout_Smart_Class,
  Elm_Container_Smart_Class, elm_container_smart_class_get, _smart_callbacks);

EAPI const Elm_Layout_Smart_Class *
elm_layout_smart_class_get(void)
{
   static Elm_Layout_Smart_Class _sc =
{'fraction_non_alphanumeric': 0.08339197748064743, 'fraction_numerical': 0.0003518648838845883, 'mean_word_length': 3.4763779527559056, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4699068', 'n_tokens_mistral': 2015, 'n_tokens_neox': 1959, 'n_words': 450}