Kaydet (Commit) 58b05ce9 authored tarafından Michael Meeks's avatar Michael Meeks

fdo#59881 - sdremote: give up on threaded / UNO usage.

Process incoming commands in the main thread in a Timeout, build
thumbnail / previews there too - to avoid the deadlocks mentioned
in the bug.

Change-Id: I5f5e8d6fbc2e059d4194f72f3e086e1aa87ab2cc
üst f99e5408
...@@ -79,7 +79,7 @@ void Communicator::execute() ...@@ -79,7 +79,7 @@ void Communicator::execute()
} }
else else
{ {
aReceiver.parseCommand( aCommand ); aReceiver.pushCommand( aCommand );
aCommand.clear(); aCommand.clear();
} }
} }
......
...@@ -50,36 +50,31 @@ ImagePreparer::ImagePreparer( ...@@ -50,36 +50,31 @@ ImagePreparer::ImagePreparer(
: xController( rxController ), : xController( rxController ),
pTransmitter( aTransmitter ) pTransmitter( aTransmitter )
{ {
SetTimeout( 50 );
mnSendingSlide = 0;
Start();
} }
ImagePreparer::~ImagePreparer() ImagePreparer::~ImagePreparer()
{ {
Stop();
} }
void SAL_CALL ImagePreparer::run() void SAL_CALL ImagePreparer::Timeout()
{ {
sal_uInt32 aSlides = xController->getSlideCount(); sal_uInt32 aSlides = xController->getSlideCount();
for ( sal_uInt32 i = 0; i < aSlides; i++ ) // fprintf( stderr, "ImagePreparer: %d %d %d\n", xController->isRunning(),
// (int)mnSendingSlide, (int)aSlides);
if ( xController->isRunning() && // not stopped/disposed of.
mnSendingSlide < aSlides )
{ {
if ( !xController->isRunning() ) // stopped/disposed of. sendPreview( mnSendingSlide );
{ sendNotes( mnSendingSlide );
break; mnSendingSlide++;
} Start();
sendPreview( i );
}
for ( sal_uInt32 i = 0; i < aSlides; i++ )
{
if ( !xController->isRunning() ) // stopped/disposed of.
{
break;
}
sendNotes( i );
} }
} else
Stop();
void SAL_CALL ImagePreparer::onTerminated()
{
delete this;
} }
void ImagePreparer::sendPreview( sal_uInt32 aSlideNumber ) void ImagePreparer::sendPreview( sal_uInt32 aSlideNumber )
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#define _SD_IMPRESSREMOTE_IMAGEPREPARER_HXX #define _SD_IMPRESSREMOTE_IMAGEPREPARER_HXX
#include <osl/thread.hxx> #include <osl/thread.hxx>
#include <vcl/timer.hxx>
#include <com/sun/star/presentation/XSlideShowController.hpp> #include <com/sun/star/presentation/XSlideShowController.hpp>
#include "Transmitter.hxx" #include "Transmitter.hxx"
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
namespace sd namespace sd
{ {
class ImagePreparer: class ImagePreparer : Timer
public osl::Thread
{ {
sal_uInt32 mnSendingSlide;
public: public:
ImagePreparer( const ImagePreparer( const
css::uno::Reference<css::presentation::XSlideShowController>& css::uno::Reference<css::presentation::XSlideShowController>&
...@@ -31,9 +31,7 @@ private: ...@@ -31,9 +31,7 @@ private:
css::uno::Reference<css::presentation::XSlideShowController> xController; css::uno::Reference<css::presentation::XSlideShowController> xController;
Transmitter *pTransmitter; Transmitter *pTransmitter;
// Thread method virtual void Timeout();
virtual void SAL_CALL run();
virtual void SAL_CALL onTerminated();
void sendPreview( sal_uInt32 aSlideNumber ); void sendPreview( sal_uInt32 aSlideNumber );
css::uno::Sequence<sal_Int8> preparePreview( sal_uInt32 aSlideNumber, css::uno::Sequence<sal_Int8> preparePreview( sal_uInt32 aSlideNumber,
......
...@@ -10,12 +10,13 @@ ...@@ -10,12 +10,13 @@
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <com/sun/star/presentation/XPresentationSupplier.hpp> #include <com/sun/star/presentation/XPresentationSupplier.hpp>
#include <com/sun/star/presentation/XPresentation2.hpp> #include <com/sun/star/presentation/XPresentation2.hpp>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <vcl/svapp.hxx>
#include "Listener.hxx" #include "Listener.hxx"
#include "ImagePreparer.hxx" #include "ImagePreparer.hxx"
using namespace sd; using namespace sd;
using namespace ::com::sun::star::presentation; using namespace ::com::sun::star::presentation;
using namespace ::com::sun::star::frame; using namespace ::com::sun::star::frame;
...@@ -53,8 +54,10 @@ void Listener::init( const css::uno::Reference< css::presentation::XSlideShowCon ...@@ -53,8 +54,10 @@ void Listener::init( const css::uno::Reference< css::presentation::XSlideShowCon
pTransmitter->addMessage( aBuffer.makeStringAndClear(), pTransmitter->addMessage( aBuffer.makeStringAndClear(),
Transmitter::PRIORITY_HIGH ); Transmitter::PRIORITY_HIGH );
ImagePreparer* pPreparer = new ImagePreparer( aController, pTransmitter ); {
pPreparer->create(); SolarMutexGuard aGuard;
/* ImagePreparer* pPreparer = */ new ImagePreparer( aController, pTransmitter );
}
} }
else else
{ {
......
...@@ -31,13 +31,35 @@ using namespace std; ...@@ -31,13 +31,35 @@ using namespace std;
Receiver::Receiver( Transmitter *aTransmitter ) Receiver::Receiver( Transmitter *aTransmitter )
{ {
pTransmitter = aTransmitter; pTransmitter = aTransmitter;
SetTimeout( 0 );
} }
Receiver::~Receiver() Receiver::~Receiver()
{ {
} }
void Receiver::parseCommand( std::vector<OString> aCommand ) // Bounce the commands to the main thread to avoid threading woes
void Receiver::pushCommand( const std::vector<OString> &rCommand )
{
SolarMutexGuard aGuard;
maExecQueue.push_back( rCommand );
Start();
}
void Receiver::Timeout()
{
if( maExecQueue.size() )
{
std::vector< rtl::OString > aCommands( maExecQueue.front() );
maExecQueue.pop_front();
executeCommand( aCommands );
Start();
}
else
Stop();
}
void Receiver::executeCommand( const std::vector<OString> &aCommand )
{ {
uno::Reference<presentation::XSlideShowController> xSlideShowController; uno::Reference<presentation::XSlideShowController> xSlideShowController;
uno::Reference<presentation::XPresentation2> xPresentation; uno::Reference<presentation::XPresentation2> xPresentation;
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <com/sun/star/presentation/XPresentation2.hpp> #include <com/sun/star/presentation/XPresentation2.hpp>
#include <osl/socket.hxx> #include <osl/socket.hxx>
#include <stdlib.h> #include <stdlib.h>
#include <vcl/timer.hxx>
#include <vcl/svapp.hxx>
#include <vector> #include <vector>
...@@ -24,12 +26,16 @@ ...@@ -24,12 +26,16 @@
namespace sd namespace sd
{ {
class Receiver // Timer is protected by the solar mutex => so are we.
class Receiver : Timer
{ {
std::deque< std::vector< rtl::OString > > maExecQueue;
public: public:
Receiver( Transmitter *aTransmitter ); Receiver( Transmitter *aTransmitter );
~Receiver(); ~Receiver();
void parseCommand( std::vector<rtl::OString> aCommand ); virtual void Timeout();
void pushCommand( const std::vector<rtl::OString> &rCommand );
void executeCommand( const std::vector<rtl::OString> &aCommand );
private: private:
Transmitter *pTransmitter; Transmitter *pTransmitter;
......
...@@ -2131,7 +2131,7 @@ sal_Bool SlideShowImpl::update( double & nNextTimeout ) ...@@ -2131,7 +2131,7 @@ sal_Bool SlideShowImpl::update( double & nNextTimeout )
void SlideShowImpl::notifySlideTransitionEnded( bool bPaintSlide ) void SlideShowImpl::notifySlideTransitionEnded( bool bPaintSlide )
{ {
osl::MutexGuard const guard( m_aMutex ); osl::ResettableMutexGuard guard( m_aMutex );
OSL_ENSURE( !isDisposed(), "### already disposed!" ); OSL_ENSURE( !isDisposed(), "### already disposed!" );
OSL_ENSURE( mpCurrentSlide, OSL_ENSURE( mpCurrentSlide,
...@@ -2144,6 +2144,10 @@ void SlideShowImpl::notifySlideTransitionEnded( bool bPaintSlide ) ...@@ -2144,6 +2144,10 @@ void SlideShowImpl::notifySlideTransitionEnded( bool bPaintSlide )
// the chance to register SlideStartEvents // the chance to register SlideStartEvents
const bool bBackgroundLayerRendered( !bPaintSlide ); const bool bBackgroundLayerRendered( !bPaintSlide );
mpCurrentSlide->show( bBackgroundLayerRendered ); mpCurrentSlide->show( bBackgroundLayerRendered );
uno::Reference<presentation::XSlideShow> xThis(
static_cast< presentation::XSlideShow * >( this ), uno::UNO_QUERY_THROW );
guard.reset(); // unlock
maEventMultiplexer.notifySlideStartEvent(); maEventMultiplexer.notifySlideStartEvent();
} }
} }
......
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