ecore-evas-drm: Fix broken init count

We should not assume that there is only ever 1 drm ecore_evas here so
we need to handle init count properly

@fix
This commit is contained in:
Christopher Michael 2020-04-28 12:35:07 -04:00
parent e6a6218697
commit 410fb16d6c
1 changed files with 24 additions and 18 deletions

View File

@ -142,9 +142,8 @@ _drm_device_change(void *d EINA_UNUSED, int t EINA_UNUSED, void *event)
static int
_ecore_evas_drm_init(Ecore_Evas *ee, Ecore_Evas_Engine_Drm_Data *edata, const char *device)
{
// XXX: this is broken. we init once but in a per ecore evas struct so
// we assume there will be only 1 of these drm ecore evas's ever...
if (++_drm_init_count != 1) return _drm_init_count;
_drm_init_count++;
if (_drm_init_count > 1) return _drm_init_count;
if (!ecore_drm2_init())
{
@ -201,24 +200,31 @@ static int
_ecore_evas_drm_shutdown(Ecore_Evas_Engine_Drm_Data *edata)
{
Ecore_Event_Handler *h;
if (--_drm_init_count != 0) return _drm_init_count;
if (edata->focus_job)
_drm_init_count--;
if (_drm_init_count == 0)
{
ecore_job_del(edata->focus_job);
edata->focus_job = NULL;
}
if (edata->dev)
{
ecore_drm2_outputs_destroy(edata->dev);
ecore_drm2_device_close(edata->dev);
edata->dev = NULL;
}
ecore_drm2_shutdown();
ecore_event_evas_shutdown();
EINA_LIST_FREE(handlers, h)
ecore_event_handler_del(h);
if (edata->focus_job)
{
ecore_job_del(edata->focus_job);
edata->focus_job = NULL;
}
if (edata->dev)
{
ecore_drm2_outputs_destroy(edata->dev);
ecore_drm2_device_close(edata->dev);
edata->dev = NULL;
}
ecore_drm2_shutdown();
ecore_event_evas_shutdown();
EINA_LIST_FREE(handlers, h)
ecore_event_handler_del(h);
}
if (_drm_init_count < 0) _drm_init_count = 0;
return _drm_init_count;
}