From eceecde6ccc69004898cf657bc75a140c388614f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 18 Jan 2017 09:34:32 +0200 Subject: use rtl::Reference in MediaWindowImpl instead of storing both a raw pointer and an uno::Reference Change-Id: Id42d43e14b573d48310b9e353667da80d171110e --- avmedia/source/viewer/mediawindow_impl.cxx | 23 ++++++++++++----------- avmedia/source/viewer/mediawindow_impl.hxx | 3 +-- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'avmedia') diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index 5566251e9f48..25cd07f03f51 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -129,7 +129,6 @@ MediaWindowImpl::MediaWindowImpl(vcl::Window* pParent, MediaWindow* pMediaWindow , DropTargetHelper(this) , DragSourceHelper(this) , mpMediaWindow(pMediaWindow) - , mpEvents(nullptr) , mbEventTransparent(true) , mpMediaWindowControl(bInternalMediaControl ? VclPtr::Create(this) : nullptr) , mpEmptyBmpEx(nullptr) @@ -149,14 +148,15 @@ MediaWindowImpl::~MediaWindowImpl() void MediaWindowImpl::dispose() { - if (mpEvents) - mpEvents->cleanUp(); + if (mxEvents.is()) + mxEvents->cleanUp(); if (mxPlayerWindow.is()) { - mxPlayerWindow->removeKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) ); - mxPlayerWindow->removeMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) ); - mxPlayerWindow->removeMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) ); + auto pEventsIf = static_cast(mxEvents.get()); + mxPlayerWindow->removeKeyListener( uno::Reference< awt::XKeyListener >( pEventsIf, uno::UNO_QUERY ) ); + mxPlayerWindow->removeMouseListener( uno::Reference< awt::XMouseListener >( pEventsIf, uno::UNO_QUERY ) ); + mxPlayerWindow->removeMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( pEventsIf, uno::UNO_QUERY ) ); uno::Reference< lang::XComponent > xComponent( mxPlayerWindow, uno::UNO_QUERY ); if (xComponent.is()) @@ -455,7 +455,7 @@ void MediaWindowImpl::onURLChanged() if (!mpChildWindow) return; mpChildWindow->SetHelpId(HID_AVMEDIA_PLAYERWINDOW); - mxEventsIf.set(static_cast(mpEvents = new MediaEventListenersImpl(*mpChildWindow.get()))); + mxEvents = new MediaEventListenersImpl(*mpChildWindow.get()); if (mxPlayer.is()) { @@ -482,10 +482,11 @@ void MediaWindowImpl::onURLChanged() if( xPlayerWindow.is() ) { - xPlayerWindow->addKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) ); - xPlayerWindow->addMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) ); - xPlayerWindow->addMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) ); - xPlayerWindow->addFocusListener( uno::Reference< awt::XFocusListener >( mxEventsIf, uno::UNO_QUERY ) ); + auto pEventsIf = static_cast(mxEvents.get()); + xPlayerWindow->addKeyListener( uno::Reference< awt::XKeyListener >( pEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->addMouseListener( uno::Reference< awt::XMouseListener >( pEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->addMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( pEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->addFocusListener( uno::Reference< awt::XFocusListener >( pEventsIf, uno::UNO_QUERY ) ); } } else diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx index 649a99874302..c179a9e55110 100644 --- a/avmedia/source/viewer/mediawindow_impl.hxx +++ b/avmedia/source/viewer/mediawindow_impl.hxx @@ -147,8 +147,7 @@ private: css::uno::Reference mxPlayerWindow; MediaWindow* mpMediaWindow; - css::uno::Reference mxEventsIf; - MediaEventListenersImpl* mpEvents; + rtl::Reference mxEvents; bool mbEventTransparent; VclPtr mpChildWindow; VclPtr mpMediaWindowControl; -- cgit