[Libreoffice-commits] core.git: avmedia/source

Arnaud Versini arnaud.versini at gmail.com
Mon Jun 5 07:12:01 UTC 2017


 avmedia/source/win/window.cxx |   46 ++++++++++--------------------------------
 1 file changed, 11 insertions(+), 35 deletions(-)

New commits:
commit 8fa4b0429b514c0d696ebfc2e47418292d7ec367
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Sun Jun 4 21:30:37 2017 +0200

    avmedia : Simplify Window::Window
    
    Change-Id: Idf5dc2814d2c4eb8e3a20a0e32e08839d2e6c5f7
    Reviewed-on: https://gerrit.libreoffice.org/38392
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/avmedia/source/win/window.cxx b/avmedia/source/win/window.cxx
index 9886ada2b5a1..8b31cbb2fa61 100644
--- a/avmedia/source/win/window.cxx
+++ b/avmedia/source/win/window.cxx
@@ -41,24 +41,6 @@ using namespace ::com::sun::star;
 
 namespace avmedia { namespace win {
 
-static ::osl::Mutex& ImplGetOwnStaticMutex()
-{
-    static ::osl::Mutex* pMutex = nullptr;
-
-    if( pMutex == nullptr )
-    {
-        ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-
-        if( pMutex == nullptr )
-        {
-            static ::osl::Mutex aMutex;
-            pMutex = &aMutex;
-        }
-    }
-
-    return *pMutex;
-}
-
 LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
 {
     Window* pWindow = reinterpret_cast<Window*>(::GetWindowLongPtr( hWnd, 0 ));
@@ -159,21 +141,18 @@ LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM n
 
 WNDCLASS* lcl_getWndClass()
 {
-    static WNDCLASS* s_pWndClass = nullptr;
-    if ( !s_pWndClass )
-    {
-        s_pWndClass = new WNDCLASS;
+    WNDCLASS* s_pWndClass = new WNDCLASS;
 
-        memset( s_pWndClass, 0, sizeof( *s_pWndClass ) );
-        s_pWndClass->hInstance = GetModuleHandle( nullptr );
-        s_pWndClass->cbWndExtra = sizeof( DWORD );
-        s_pWndClass->lpfnWndProc = MediaPlayerWndProc;
-        s_pWndClass->lpszClassName = "com_sun_star_media_PlayerWnd";
-        s_pWndClass->hbrBackground = static_cast<HBRUSH>(::GetStockObject( BLACK_BRUSH ));
-        s_pWndClass->hCursor = ::LoadCursor( nullptr, IDC_ARROW );
+    memset( s_pWndClass, 0, sizeof( *s_pWndClass ) );
+    s_pWndClass->hInstance = GetModuleHandle( nullptr );
+    s_pWndClass->cbWndExtra = sizeof( DWORD );
+    s_pWndClass->lpfnWndProc = MediaPlayerWndProc;
+    s_pWndClass->lpszClassName = "com_sun_star_media_PlayerWnd";
+    s_pWndClass->hbrBackground = static_cast<HBRUSH>(::GetStockObject( BLACK_BRUSH ));
+    s_pWndClass->hCursor = ::LoadCursor( nullptr, IDC_ARROW );
+
+    ::RegisterClass( s_pWndClass );
 
-        ::RegisterClass( s_pWndClass );
-    }
     return s_pWndClass;
 }
 
@@ -186,9 +165,6 @@ Window::Window( const uno::Reference< lang::XMultiServiceFactory >& rxMgr, Playe
     mnParentWnd( nullptr ),
     mnPointerType( awt::SystemPointer::ARROW )
 {
-    ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() );
-
-    lcl_getWndClass();
 }
 
 Window::~Window()
@@ -285,7 +261,7 @@ void Window::ImplLayoutVideoWindow()
 bool Window::create( const uno::Sequence< uno::Any >& rArguments )
 {
     IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() );
-    WNDCLASS* mpWndClass = lcl_getWndClass();
+    static WNDCLASS* mpWndClass = lcl_getWndClass();
 
     if( !mnFrameWnd && pVideoWindow && mpWndClass )
     {


More information about the Libreoffice-commits mailing list