aboutsummaryrefslogtreecommitdiffstats
path: root/reference
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-05-25 10:17:51 -0700
committerCedric BAIL <cedric@osg.samsung.com>2018-05-25 10:17:51 -0700
commit33dad0d59cd6deb64685cbd8460db6c49cf94780 (patch)
treece0fb61cbfa12bc9b61307a5d9f03abbcb79e3e7 /reference
parentFix leaks and double frees in eina_hash example (diff)
downloadexamples-33dad0d59cd6deb64685cbd8460db6c49cf94780.tar.gz
Update examples to efl_new / efl_add / efl_add_ref
Reviewers: cedric, q66, bu5hm4n Reviewed By: cedric, bu5hm4n Differential Revision: https://phab.enlightenment.org/D6058
Diffstat (limited to 'reference')
-rw-r--r--reference/c/core/src/core_io.c12
-rw-r--r--reference/c/core/src/core_loop.c8
-rw-r--r--reference/c/net/src/net_io.c10
-rw-r--r--reference/c/ui/src/ui_container.c2
-rw-r--r--reference/c/ui/src/ui_sizing.c2
-rw-r--r--reference/c/ui/src/ui_translation.c5
6 files changed, 20 insertions, 19 deletions
diff --git a/reference/c/core/src/core_io.c b/reference/c/core/src/core_io.c
index 045f88b7..dbfcca15 100644
--- a/reference/c/core/src/core_io.c
+++ b/reference/c/core/src/core_io.c
@@ -21,11 +21,11 @@ _io_write(const char *filename)
Eina_Slice content = EINA_SLICE_STR("### This is a sample string for the file io test ###");
Efl_Io_File *file;
- file = efl_add(EFL_IO_FILE_CLASS, NULL,
+ file = efl_new(EFL_IO_FILE_CLASS,
efl_file_set(efl_added, filename, NULL), // mandatory
efl_io_file_flags_set(efl_added, O_WRONLY | O_CREAT), // write and create - default is read
efl_io_file_mode_set(efl_added, 0644), // neccessary if we use O_CREAT
- efl_io_closer_close_on_destructor_set(efl_added, EINA_TRUE)); // recommended
+ efl_io_closer_close_on_invalidate_set(efl_added, EINA_TRUE)); // recommended
if (!file)
return;
@@ -41,7 +41,7 @@ _io_write(const char *filename)
free(string);
}
- efl_del(file);
+ efl_unref(file);
}
static void
@@ -50,9 +50,9 @@ _io_read(const char *filename)
EINA_RW_SLICE_DECLARE(content, 1024);
Efl_Io_File *file;
- file = efl_add(EFL_IO_FILE_CLASS, NULL,
+ file = efl_new(EFL_IO_FILE_CLASS,
efl_file_set(efl_added, filename, NULL), // mandatory
- efl_io_closer_close_on_destructor_set(efl_added, EINA_TRUE)); // recommended
+ efl_io_closer_close_on_invalidate_set(efl_added, EINA_TRUE)); // recommended
if (!file)
return;
@@ -68,7 +68,7 @@ _io_read(const char *filename)
free(string);
}
- efl_del(file);
+ efl_unref(file);
}
static void
diff --git a/reference/c/core/src/core_loop.c b/reference/c/core/src/core_loop.c
index 0e7f545f..c8011671 100644
--- a/reference/c/core/src/core_loop.c
+++ b/reference/c/core/src/core_loop.c
@@ -40,7 +40,7 @@ _read_fd_cb(void *data EINA_UNUSED, const Efl_Event *event)
// here we are exiting
if (len <= 0)
{
- efl_del(fd_obj);
+ efl_unref(fd_obj);
unlink(FILENAME);
efl_exit(0);
@@ -63,7 +63,7 @@ _write_fd_cb(void *data EINA_UNUSED, const Efl_Event *event)
// and start checking for read availability instead
if (_count >= 5)
{
- efl_del(fd_obj);
+ efl_unref(fd_obj);
_read_fd_create();
return;
@@ -81,7 +81,7 @@ _write_fd_create()
FILE *file;
int fd;
- fd_obj = efl_add(EFL_LOOP_FD_CLASS, NULL,
+ fd_obj = efl_new(EFL_LOOP_FD_CLASS,
efl_name_set(efl_added, "Write FD"));
efl_event_callback_add(fd_obj, EFL_LOOP_FD_EVENT_WRITE, _write_fd_cb, NULL);
@@ -100,7 +100,7 @@ _read_fd_create()
FILE *file;
int fd;
- fd_obj = efl_add(EFL_LOOP_FD_CLASS, NULL,
+ fd_obj = efl_new(EFL_LOOP_FD_CLASS,
efl_name_set(efl_added, "Read FD"));
efl_event_callback_add(fd_obj, EFL_LOOP_FD_EVENT_READ, _read_fd_cb, NULL);
diff --git a/reference/c/net/src/net_io.c b/reference/c/net/src/net_io.c
index 8475d4b8..6ba33dd8 100644
--- a/reference/c/net/src/net_io.c
+++ b/reference/c/net/src/net_io.c
@@ -33,14 +33,12 @@ _quit(int retval)
if (_receiver)
{
efl_io_closer_close(_receiver);
- efl_del(efl_io_copier_destination_get(_receiver));
efl_del(_receiver);
}
if (_sender)
{
efl_io_closer_close(_sender);
- efl_del(efl_io_copier_source_get(_sender));
efl_del(_sender);
}
@@ -158,7 +156,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
* the line_delimiter, then wait for a reply from the server, then
* write another.
*/
- send_queue = efl_add(EFL_IO_QUEUE_CLASS, NULL,
+ send_queue = efl_new(EFL_IO_QUEUE_CLASS,
efl_name_set(efl_added, "send_queue"),
efl_io_queue_limit_set(efl_added, buffer_limit));
if (!send_queue)
@@ -179,7 +177,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
* Our example's usage is to peek its data with slice_get() then
* clear().
*/
- receive_queue = efl_add(EFL_IO_QUEUE_CLASS, NULL,
+ receive_queue = efl_new(EFL_IO_QUEUE_CLASS,
efl_name_set(efl_added, "receive_queue"),
efl_io_queue_limit_set(efl_added, buffer_limit),
efl_event_callback_add(efl_added, EFL_IO_QUEUE_EVENT_SLICE_CHANGED, _receiver_data, NULL));
@@ -213,6 +211,8 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
efl_io_copier_source_set(efl_added, send_queue),
efl_io_copier_destination_set(efl_added, _dialer),
efl_event_callback_array_add(efl_added, copier_cbs(), NULL));
+ /* _sender took an extra ref to send_queue, so we can dispose of ours now */
+ efl_unref (send_queue);
if (!_sender)
{
fprintf(stderr, "ERROR: could not create Efl_Io_Copier (sender)\n");
@@ -226,6 +226,8 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
efl_io_copier_source_set(efl_added, _dialer),
efl_io_copier_destination_set(efl_added, receive_queue),
efl_event_callback_array_add(efl_added, copier_cbs(), NULL));
+ /* _receiver took an extra ref to receive_queue, so we can dispose of ours now */
+ efl_unref (receive_queue);
if (!_receiver)
{
fprintf(stderr, "ERROR: could not create Efl_Io_Copier (receiver)\n");
diff --git a/reference/c/ui/src/ui_container.c b/reference/c/ui/src/ui_container.c
index c98555f8..21156579 100644
--- a/reference/c/ui/src/ui_container.c
+++ b/reference/c/ui/src/ui_container.c
@@ -107,7 +107,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
Eo *win;
- win = efl_add(EFL_UI_WIN_CLASS, NULL,
+ win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Hello World"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
diff --git a/reference/c/ui/src/ui_sizing.c b/reference/c/ui/src/ui_sizing.c
index 72dfa18e..f2b8a769 100644
--- a/reference/c/ui/src/ui_sizing.c
+++ b/reference/c/ui/src/ui_sizing.c
@@ -27,7 +27,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
Efl_Ui_Win *win, *box;
- win = efl_add(EFL_UI_WIN_CLASS, NULL,
+ win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Size Control"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
diff --git a/reference/c/ui/src/ui_translation.c b/reference/c/ui/src/ui_translation.c
index 92956e10..b8aa9884 100644
--- a/reference/c/ui/src/ui_translation.c
+++ b/reference/c/ui/src/ui_translation.c
@@ -33,10 +33,9 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
Efl_Ui_Win *win, *box;
- win = efl_add(EFL_UI_WIN_CLASS, NULL,
+ win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
- efl_ui_translatable_text_set(efl_added, "Translations",
- _TEXT_DOMAIN),
+ efl_text_set(efl_added, "Translations"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
// when the user clicks "close" on a window there is a request to delete