wl_resource_set_implementation(res, &_e_manager_interface, cdata, NULL);
}
-static void
+static int
+_e_comp_wl_clipboard_source_ref(E_Comp_Wl_Clipboard_Source *source)
+{
+ source->ref ++;
+ return source->ref;
+}
+
+static int
_e_comp_wl_clipboard_source_unref(E_Comp_Wl_Clipboard_Source *source)
{
char* t;
source->ref --;
- if (source->ref > 0) return;
+ if (source->ref > 0)
+ return source->ref;
if (source->fd_handler)
{
wl_signal_emit(&source->data_source.destroy_signal, &source->data_source);
wl_array_release(&source->contents);
free(source);
+
+ return 0;
}
static Eina_Bool
offer->offset = 0;
offer->source = source;
- source->ref++;
+
+ _e_comp_wl_clipboard_source_ref(source);
+
offer->fd_handler =
ecore_main_fd_handler_add(fd, ECORE_FD_WRITE,
_e_comp_wl_clipboard_offer_load, offer,
}
else if (len < 0)
{
- _e_comp_wl_clipboard_source_unref(source);
- cdata->clipboard.source = NULL;
+ if (!(_e_comp_wl_clipboard_source_unref(source)))
+ cdata->clipboard.source = NULL;
}
else
{
else if (sel_source->target == _e_comp_wl_clipboard_source_target_send)
return;
- if (clip_source)
- _e_comp_wl_clipboard_source_unref(clip_source);
-
- cdata->clipboard.source = NULL;
mime_type = eina_list_nth(sel_source->mime_types, 0);
- if (pipe2(p, O_CLOEXEC) == -1)
- return;
-
- sel_source->send(sel_source, mime_type, p[1]);
+ if (!clip_source)
+ {
+ if (pipe2(p, O_CLOEXEC) == -1)
+ return;
- cdata->clipboard.source =
- _e_comp_wl_clipboard_source_create(cdata, mime_type,
- cdata->selection.serial, p);
+ sel_source->send(sel_source, mime_type, p[1]);
- if (!cdata->clipboard.source)
+ cdata->clipboard.source =
+ _e_comp_wl_clipboard_source_create(cdata, mime_type,
+ cdata->selection.serial, p);
+ if (!cdata->clipboard.source)
+ {
+ close(p[0]);
+ close(p[1]);
+ }
+ }
+ else
{
- close(p[0]);
- close(p[1]);
+ sel_source->send(sel_source, mime_type, clip_source->fd[1]);
+
}
}