vcl/inc/unx/gtk/gtkdata.hxx  |   12 ++++++------
 vcl/unx/gtk/gtkdata.cxx      |   11 +++++------
 vcl/unx/gtk3/gtk3gtkdata.cxx |   11 +++++------
 3 files changed, 16 insertions(+), 18 deletions(-)

New commits:
commit 5198b4b8c7a7086753e499900b227e16f3d65340
Author: Chris Sherlock <chris.sherloc...@gmail.com>
Date:   Sat Mar 18 18:49:10 2017 +1100

    vcl: make GtkData use osl::Condition instead of oslCondition
    
    Condition is deprecated already, but there is no need for the
    GtkData class to use the low-level C-API, when in fact there is a C++
    fascade that calls on this via the C++ abstraction, osl::Condition.
    
    This will make it much easier to switch to using std::condition_variable
    in the future.
    
    Change-Id: Iddd2cad0e1137c0b458ebe25b506d463847a6dc0
    Reviewed-on: https://gerrit.libreoffice.org/35389
    Reviewed-by: Chris Sherlock <chris.sherloc...@gmail.com>
    Tested-by: Chris Sherlock <chris.sherloc...@gmail.com>

diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index ffb0fb700718..69ff7f479478 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -29,7 +29,7 @@
 #include <unx/saldisp.hxx>
 #include <unx/gtk/gtksys.hxx>
 #include <vcl/ptrstyle.hxx>
-#include <osl/conditn.h>
+#include <osl/conditn.hxx>
 #include "saltimer.hxx"
 #include <o3tl/enumarray.hxx>
 
@@ -94,11 +94,11 @@ public:
 
 class GtkData : public SalGenericData
 {
-    GSource*     m_pUserEvent;
-    osl::Mutex   m_aDispatchMutex;
-    oslCondition m_aDispatchCondition;
-    css::uno::Any m_aException;
-    bool         blockIdleTimeout;
+    GSource*        m_pUserEvent;
+    osl::Mutex      m_aDispatchMutex;
+    osl::Condition  m_aDispatchCondition;
+    css::uno::Any   m_aException;
+    bool            blockIdleTimeout;
 
 public:
     GtkData( SalInstance *pInstance );
diff --git a/vcl/unx/gtk/gtkdata.cxx b/vcl/unx/gtk/gtkdata.cxx
index a0ba64dc4074..036b83accdbe 100644
--- a/vcl/unx/gtk/gtkdata.cxx
+++ b/vcl/unx/gtk/gtkdata.cxx
@@ -405,10 +405,10 @@ int GtkSalDisplay::CaptureMouse( SalFrame* pSFrame )
 GtkData::GtkData( SalInstance *pInstance )
     : SalGenericData( SAL_DATA_GTK, pInstance )
     , m_aDispatchMutex()
+    , m_aDispatchCondition()
     , blockIdleTimeout( false )
 {
     m_pUserEvent = nullptr;
-    m_aDispatchCondition = osl_createCondition();
 }
 
 static XIOErrorHandler aOrigXIOErrorHandler = nullptr;
@@ -432,7 +432,7 @@ GtkData::~GtkData()
 
      // sanity check: at this point nobody should be yielding, but wake them
      // up anyway before the condition they're waiting on gets destroyed.
-    osl_setCondition( m_aDispatchCondition );
+    m_aDispatchCondition.set();
 
     osl::MutexGuard g( m_aDispatchMutex );
     if (m_pUserEvent)
@@ -441,7 +441,6 @@ GtkData::~GtkData()
         g_source_unref (m_pUserEvent);
         m_pUserEvent = nullptr;
     }
-    osl_destroyCondition( m_aDispatchCondition );
     XSetIOErrorHandler(aOrigXIOErrorHandler);
 }
 
@@ -491,9 +490,9 @@ SalYieldResult GtkData::Yield( bool bWait, bool 
bHandleAllCurrentEvents )
              * workaround: timeout of 1 second a emergency exit
              */
             // we are the dispatch thread
-            osl_resetCondition( m_aDispatchCondition );
+            m_aDispatchCondition.reset();
             TimeValue aValue = { 1, 0 };
-            osl_waitCondition( m_aDispatchCondition, &aValue );
+            m_aDispatchCondition.wait( &aValue );
         }
     }
 
@@ -501,7 +500,7 @@ SalYieldResult GtkData::Yield( bool bWait, bool 
bHandleAllCurrentEvents )
     {
         m_aDispatchMutex.release();
         if( bWasEvent )
-            osl_setCondition( m_aDispatchCondition ); // trigger non dispatch 
thread yields
+            m_aDispatchCondition.set(); // trigger non dispatch thread yields
     }
     blockIdleTimeout = false;
 
diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx
index 03e70ec83e66..7e6ea43c6b61 100644
--- a/vcl/unx/gtk3/gtk3gtkdata.cxx
+++ b/vcl/unx/gtk3/gtk3gtkdata.cxx
@@ -368,10 +368,10 @@ int GtkSalDisplay::CaptureMouse( SalFrame* pSFrame )
 GtkData::GtkData( SalInstance *pInstance )
     : SalGenericData( SAL_DATA_GTK3, pInstance )
     , m_aDispatchMutex()
+    , m_aDispatchCondition()
     , blockIdleTimeout( false )
 {
     m_pUserEvent = nullptr;
-    m_aDispatchCondition = osl_createCondition();
 }
 
 #if defined(GDK_WINDOWING_X11)
@@ -397,7 +397,7 @@ GtkData::~GtkData()
 
      // sanity check: at this point nobody should be yielding, but wake them
      // up anyway before the condition they're waiting on gets destroyed.
-    osl_setCondition( m_aDispatchCondition );
+     m_aDispatchCondition.set();
 
     osl::MutexGuard g( m_aDispatchMutex );
     if (m_pUserEvent)
@@ -406,7 +406,6 @@ GtkData::~GtkData()
         g_source_unref (m_pUserEvent);
         m_pUserEvent = nullptr;
     }
-    osl_destroyCondition( m_aDispatchCondition );
 #if defined(GDK_WINDOWING_X11)
     if (GDK_IS_X11_DISPLAY(gdk_display_get_default()))
         XSetIOErrorHandler(aOrigXIOErrorHandler);
@@ -461,9 +460,9 @@ SalYieldResult GtkData::Yield( bool bWait, bool 
bHandleAllCurrentEvents )
              * workaround: timeout of 1 second a emergency exit
              */
             // we are the dispatch thread
-            osl_resetCondition( m_aDispatchCondition );
+            m_aDispatchCondition.reset();
             TimeValue aValue = { 1, 0 };
-            osl_waitCondition( m_aDispatchCondition, &aValue );
+            m_aDispatchCondition.wait(&aValue);
         }
     }
 
@@ -471,7 +470,7 @@ SalYieldResult GtkData::Yield( bool bWait, bool 
bHandleAllCurrentEvents )
     {
         m_aDispatchMutex.release();
         if( bWasEvent )
-            osl_setCondition( m_aDispatchCondition ); // trigger non dispatch 
thread yields
+            m_aDispatchCondition.set(); // trigger non dispatch thread yields
     }
     blockIdleTimeout = false;
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to