devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=410fb16d6cf2f65f4e1c6de12712359547e67862

commit 410fb16d6cf2f65f4e1c6de12712359547e67862
Author: Christopher Michael <[email protected]>
Date:   Tue Apr 28 12:35:07 2020 -0400

    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
---
 .../ecore_evas/engines/drm/ecore_evas_drm.c        | 40 +++++++++++++---------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index 35eadc002b..3953b3323d 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -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;
+        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);
      }
-   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;
 }
 

-- 


Reply via email to