Kaydet (Commit) 4ab63a3a authored tarafından Thorsten Behrens's avatar Thorsten Behrens

Fix race & deadlock in sdremote

Neither deleting the thread from the outside, nor keeping a reference
inside the thread to an object that might die beforehand is a
terribly good idea. Thread now commits suicide when loop finishes.

Change-Id: Ia97903765cde1d340d5bcc8161e6fa6b699d0047
üst ee815252
......@@ -54,11 +54,10 @@ using namespace ::com::sun::star::uno;
ImagePreparer::ImagePreparer(
const uno::Reference<presentation::XSlideShowController>& rxController,
Transmitter *aTransmitter, rtl::Reference<ImagePreparer>& rRef )
Transmitter *aTransmitter )
: Thread( "ImagePreparer Thread" ),
xController( rxController ),
pTransmitter( aTransmitter ),
mRef( rRef )
pTransmitter( aTransmitter )
{
}
......@@ -85,7 +84,7 @@ void ImagePreparer::execute()
}
sendNotes( i );
}
mRef.clear();
delete this;
}
void ImagePreparer::sendPreview( sal_uInt32 aSlideNumber )
......
......@@ -10,7 +10,6 @@
#define _SD_IMPRESSREMOTE_IMAGEPREPARER_HXX
#include <salhelper/thread.hxx>
#include <rtl/ref.hxx>
#include <com/sun/star/presentation/XSlideShowController.hpp>
......@@ -27,14 +26,12 @@ class ImagePreparer:
public:
ImagePreparer( const
css::uno::Reference<css::presentation::XSlideShowController>&
rxController, sd::Transmitter *aTransmitter,
rtl::Reference<ImagePreparer>& rRef );
rxController, sd::Transmitter *aTransmitter );
~ImagePreparer();
private:
css::uno::Reference<css::presentation::XSlideShowController> xController;
Transmitter *pTransmitter;
rtl::Reference<ImagePreparer>& mRef;
// Thread method
void execute();
......
......@@ -26,8 +26,7 @@ Listener::Listener( const ::rtl::Reference<Communicator>& rCommunicator,
sd::Transmitter *aTransmitter ):
::cppu::WeakComponentImplHelper1< XSlideShowListener >( m_aMutex ),
mCommunicator( rCommunicator ),
pTransmitter( NULL ),
mPreparer()
pTransmitter( NULL )
{
pTransmitter = aTransmitter;
}
......@@ -53,8 +52,8 @@ void Listener::init( const css::uno::Reference< css::presentation::XSlideShowCon
pTransmitter->addMessage( aBuffer.makeStringAndClear(),
Transmitter::PRIORITY_HIGH );
mPreparer.set( new ImagePreparer( aController, pTransmitter, mPreparer ) );
mPreparer->launch();
ImagePreparer* pPreparer = new ImagePreparer( aController, pTransmitter );
pPreparer->launch();
}
else
{
......@@ -135,12 +134,6 @@ void SAL_CALL Listener::slideAnimationsEnded (void)
void SAL_CALL Listener::disposing (void)
{
if ( mPreparer.is() )
{
delete mPreparer.get();
mPreparer = NULL;
}
pTransmitter = NULL;
if ( mController.is() )
{
......@@ -157,4 +150,4 @@ void SAL_CALL Listener::disposing (
(void) rEvent;
dispose();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -17,7 +17,6 @@
#include <cppuhelper/compbase1.hxx>
#include <cppuhelper/basemutex.hxx>
#include <osl/socket.hxx>
#include <rtl/ref.hxx>
#include "Communicator.hxx"
#include "Transmitter.hxx"
......@@ -68,7 +67,6 @@ private:
rtl::Reference<Communicator> mCommunicator;
sd::Transmitter *pTransmitter;
css::uno::Reference< css::presentation::XSlideShowController > mController;
rtl::Reference<sd::ImagePreparer> mPreparer;
};
}
#endif // _SD_IMPRESSREMOTE_LISTENER_HXX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment