[Libreoffice-commits] .: 14 commits - binaryurp/source comphelper/inc comphelper/Library_comphelp.mk comphelper/prj comphelper/source configmgr/source cui/Library_cui.mk cui/prj cui/source dbaccess/source desktop/Library_deploymentgui.mk desktop/Library_sofficeapp.mk desktop/prj desktop/source extensions/Library_pcr.mk extensions/prj extensions/source filter/Library_filterconfig.mk filter/Library_xsltfilter.mk filter/prj filter/source forms/Library_frm.mk forms/prj forms/source jvmfwk/plugins pyuno/prj pyuno/source salhelper/inc salhelper/Library_salhelper.mk salhelper/Package_inc.mk salhelper/source sal/inc sal/Package_inc.mk svtools/inc svtools/source ucb/source
Stephan Bergmann
sbergmann at kemper.freedesktop.org
Thu Feb 23 01:48:57 PST 2012
binaryurp/source/bridge.cxx | 6
binaryurp/source/reader.cxx | 12 -
binaryurp/source/reader.hxx | 21 --
binaryurp/source/writer.cxx | 11 -
binaryurp/source/writer.hxx | 20 --
comphelper/Library_comphelp.mk | 5
comphelper/inc/comphelper/asyncnotification.hxx | 33 +--
comphelper/prj/build.lst | 2
comphelper/source/misc/asyncnotification.cxx | 37 ---
configmgr/source/components.cxx | 25 --
cui/Library_cui.mk | 1
cui/prj/build.lst | 2
cui/source/dialogs/cuigaldlg.cxx | 45 ++--
cui/source/inc/cuigaldlg.hxx | 25 +-
dbaccess/source/core/dataaccess/documenteventnotifier.cxx | 9
desktop/Library_deploymentgui.mk | 1
desktop/Library_sofficeapp.mk | 1
desktop/prj/build.lst | 2
desktop/source/app/officeipcthread.cxx | 49 ++---
desktop/source/app/officeipcthread.hxx | 18 +
desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx | 18 -
desktop/source/deployment/gui/dp_gui_thread.cxx | 83 --------
desktop/source/deployment/gui/dp_gui_thread.hxx | 87 ---------
desktop/source/deployment/gui/dp_gui_updatedialog.cxx | 8
desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx | 8
extensions/Library_pcr.mk | 1
extensions/prj/build.lst | 2
extensions/source/propctrlr/browserlistbox.cxx | 9
filter/Library_filterconfig.mk | 1
filter/Library_xsltfilter.mk | 1
filter/prj/build.lst | 2
filter/source/config/cache/lateinitlistener.cxx | 15 -
filter/source/config/cache/lateinitthread.cxx | 49 +----
filter/source/config/cache/lateinitthread.hxx | 58 +-----
filter/source/xsltdialog/xmlfiltertabpagexslt.cxx | 6
filter/source/xsltfilter/LibXSLTTransformer.cxx | 47 ++--
filter/source/xsltfilter/LibXSLTTransformer.hxx | 46 ++--
filter/source/xsltfilter/OleHandler.hxx | 10 -
filter/source/xsltfilter/XSLTFilter.cxx | 78 ++++----
forms/Library_frm.mk | 1
forms/prj/build.lst | 2
forms/source/component/ListBox.cxx | 11 -
jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 24 +-
pyuno/prj/build.lst | 2
pyuno/source/module/makefile.mk | 1
pyuno/source/module/pyuno_gc.cxx | 50 ++---
sal/Package_inc.mk | 1
sal/inc/osl/thread.hxx | 7
sal/inc/sal/log-areas.dox | 50 ++---
salhelper/Library_salhelper.mk | 1
salhelper/Package_inc.mk | 1
salhelper/inc/salhelper/thread.hxx | 104 +++++++++++
salhelper/source/gcc3.map | 18 +
salhelper/source/thread.cxx | 66 ++++++
svtools/inc/svtools/inettbc.hxx | 3
svtools/source/contnr/contentenumeration.cxx | 44 ----
svtools/source/contnr/contentenumeration.hxx | 16 -
svtools/source/contnr/fileview.cxx | 8
svtools/source/control/inettbc.cxx | 66 +++---
ucb/source/ucp/webdav/NeonLockStore.cxx | 26 +-
ucb/source/ucp/webdav/NeonLockStore.hxx | 2
61 files changed, 613 insertions(+), 745 deletions(-)
New commits:
commit d6b39054fc0d47e01f01954279abf3ba3d8e9242
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:47:03 2012 +0100
Adapted Reader to safer-to-use salhelper::Thread
...which required some Reference namespace clean up.
diff --git a/filter/Library_xsltfilter.mk b/filter/Library_xsltfilter.mk
index 5a103e0..b9e7a6e 100644
--- a/filter/Library_xsltfilter.mk
+++ b/filter/Library_xsltfilter.mk
@@ -40,6 +40,7 @@ $(eval $(call gb_Library_add_linked_libs,xsltfilter,\
cppuhelper \
cppu \
sal \
+ salhelper \
$(gb_STDLIBS) \
))
diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx b/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx
index 9df711f..1a58173 100644
--- a/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx
+++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx
@@ -44,7 +44,9 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
-XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, const Reference< XMultiServiceFactory >& rxMSF ) :
+namespace css = com::sun::star;
+
+XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, const css::uno::Reference< XMultiServiceFactory >& rxMSF ) :
TabPage( pParent, ResId( RID_XML_FILTER_TABPAGE_XSLT, rResMgr ) ),
maFTDocType( this, ResId( FT_XML_DOCTYPE, rResMgr ) ),
@@ -80,7 +82,7 @@ XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, co
try
{
- Reference< XConfigManager > xCfgMgr( rxMSF->createInstance(OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.config.SpecialConfigManager" ))), UNO_QUERY );
+ css::uno::Reference< XConfigManager > xCfgMgr( rxMSF->createInstance(OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.config.SpecialConfigManager" ))), UNO_QUERY );
if( xCfgMgr.is() )
sInstPath = xCfgMgr->substituteVariables( sInstPath );
}
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx
index 599b80c..ff57fc1 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.cxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx
@@ -79,6 +79,8 @@ using ::std::list;
using ::std::map;
using ::std::pair;
+namespace css = com::sun::star;
+
#define _INPUT_BUFFER_SIZE 4096
#define _OUTPUT_BUFFER_SIZE 4096
@@ -228,8 +230,8 @@ namespace XSLT
};
Reader::Reader(LibXSLTTransformer* transformer) :
- m_transformer(transformer), m_terminated(false), m_readBuf(
- INPUT_BUFFER_SIZE), m_writeBuf(OUTPUT_BUFFER_SIZE)
+ Thread("LibXSLTTransformer"), m_transformer(transformer),
+ m_readBuf(INPUT_BUFFER_SIZE), m_writeBuf(OUTPUT_BUFFER_SIZE)
{
LIBXML_TEST_VERSION;
}
@@ -242,7 +244,7 @@ namespace XSLT
if (buffer == NULL || len < 0)
return (-1);
sal_Int32 n;
- Reference<XInputStream> xis = this->m_transformer->getInputStream();
+ css::uno::Reference<XInputStream> xis = this->m_transformer->getInputStream();
n = xis.get()->readBytes(m_readBuf, len);
if (n > 0)
{
@@ -258,7 +260,7 @@ namespace XSLT
return -1;
if (len > 0)
{
- Reference<XOutputStream> xos = m_transformer->getOutputStream();
+ css::uno::Reference<XOutputStream> xos = m_transformer->getOutputStream();
sal_Int32 writeLen = len;
sal_Int32 bufLen = ::std::min(writeLen,
this->OUTPUT_BUFFER_SIZE);
@@ -287,7 +289,7 @@ namespace XSLT
int
Reader::closeOutput()
{
- Reference<XOutputStream> xos = m_transformer->getOutputStream();
+ css::uno::Reference<XOutputStream> xos = m_transformer->getOutputStream();
if (xos.is())
{
xos.get()->flush();
@@ -298,7 +300,7 @@ namespace XSLT
}
void
- Reader::run()
+ Reader::execute()
{
OSL_ASSERT(m_transformer != NULL);
OSL_ASSERT(m_transformer->getInputStream().is());
@@ -363,11 +365,6 @@ namespace XSLT
}
void
- Reader::onTerminated()
- {
- m_terminated = true;
- }
- void
Reader::registerExtensionModule()
{
const xmlChar* oleModuleURI = (const xmlChar *) EXT_MODULE_OLE_URI;
@@ -388,20 +385,20 @@ namespace XSLT
}
LibXSLTTransformer::LibXSLTTransformer(
- const Reference<XMultiServiceFactory> &r) :
- m_rServiceFactory(r), m_Reader(NULL)
+ const css::uno::Reference<XMultiServiceFactory> &r) :
+ m_rServiceFactory(r)
{
}
void
LibXSLTTransformer::setInputStream(
- const Reference<XInputStream>& inputStream)
+ const css::uno::Reference<XInputStream>& inputStream)
throw (RuntimeException)
{
m_rInputStream = inputStream;
}
- Reference<XInputStream>
+ css::uno::Reference<XInputStream>
LibXSLTTransformer::getInputStream() throw (RuntimeException)
{
return m_rInputStream;
@@ -409,20 +406,20 @@ namespace XSLT
void
LibXSLTTransformer::setOutputStream(
- const Reference<XOutputStream>& outputStream)
+ const css::uno::Reference<XOutputStream>& outputStream)
throw (RuntimeException)
{
m_rOutputStream = outputStream;
}
- Reference<XOutputStream>
+ css::uno::Reference<XOutputStream>
LibXSLTTransformer::getOutputStream() throw (RuntimeException)
{
return m_rOutputStream;
}
void
- LibXSLTTransformer::addListener(const Reference<XStreamListener>& listener)
+ LibXSLTTransformer::addListener(const css::uno::Reference<XStreamListener>& listener)
throw (RuntimeException)
{
m_listeners.insert(m_listeners.begin(), listener);
@@ -430,7 +427,7 @@ namespace XSLT
void
LibXSLTTransformer::removeListener(
- const Reference<XStreamListener>& listener)
+ const css::uno::Reference<XStreamListener>& listener)
throw (RuntimeException)
{
m_listeners.remove(listener);
@@ -443,12 +440,12 @@ namespace XSLT
ListenerList* l = &m_listeners;
for (it = l->begin(); it != l->end(); ++it)
{
- Reference<XStreamListener> xl = *it;
+ css::uno::Reference<XStreamListener> xl = *it;
xl.get()->started();
}
- OSL_ENSURE(m_Reader == NULL, "Somebody forgot to call terminate *and* holds a reference to this LibXSLTTransformer instance");
+ OSL_ENSURE(!m_Reader.is(), "Somebody forgot to call terminate *and* holds a reference to this LibXSLTTransformer instance");
m_Reader = new Reader(this);
- m_Reader->create();
+ m_Reader->launch();
}
void
@@ -459,7 +456,7 @@ namespace XSLT
arg <<= Exception(msg, *this);
for (ListenerList::iterator it = l->begin(); it != l->end(); ++it)
{
- Reference<XStreamListener> xl = *it;
+ css::uno::Reference<XStreamListener> xl = *it;
if (xl.is())
{
xl.get()->error(arg);
@@ -473,7 +470,7 @@ namespace XSLT
ListenerList* l = &m_listeners;
for (ListenerList::iterator it = l->begin(); it != l->end(); ++it)
{
- Reference<XStreamListener> xl = *it;
+ css::uno::Reference<XStreamListener> xl = *it;
if (xl.is())
{
xl.get()->closed();
@@ -486,7 +483,7 @@ namespace XSLT
{
m_Reader->terminate();
m_Reader->join();
- delete(m_Reader);
+ m_Reader.clear();
m_parameters.clear();
}
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.hxx b/filter/source/xsltfilter/LibXSLTTransformer.hxx
index 379b715..444cb2f 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.hxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.hxx
@@ -45,7 +45,9 @@
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/implbase.hxx>
-#include <osl/thread.hxx>
+#include <rtl/ref.hxx>
+
+#include <salhelper/thread.hxx>
#include <com/sun/star/uno/Any.hxx>
@@ -100,13 +102,13 @@ namespace XSLT
static const char* const PARAM_DOCTYPE_PUBLIC;
// the UNO ServiceFactory
- Reference<XMultiServiceFactory> m_rServiceFactory;
+ com::sun::star::uno::Reference<XMultiServiceFactory> m_rServiceFactory;
- Reference<XInputStream> m_rInputStream;
+ com::sun::star::uno::Reference<XInputStream> m_rInputStream;
- Reference<XOutputStream> m_rOutputStream;
+ com::sun::star::uno::Reference<XOutputStream> m_rOutputStream;
- typedef ::std::list<Reference<XStreamListener> > ListenerList;
+ typedef ::std::list<com::sun::star::uno::Reference<XStreamListener> > ListenerList;
ListenerList m_listeners;
@@ -114,39 +116,39 @@ namespace XSLT
::std::map<const char *, OString> m_parameters;
- osl::Thread* m_Reader;
+ rtl::Reference< salhelper::Thread > m_Reader;
protected:
virtual ~LibXSLTTransformer() {
- if (m_Reader) {
+ if (m_Reader.is()) {
m_Reader->terminate();
+ m_Reader->join();
}
- delete(m_Reader);
}
public:
// ctor...
- LibXSLTTransformer(const Reference<XMultiServiceFactory> &r);
+ LibXSLTTransformer(const com::sun::star::uno::Reference<XMultiServiceFactory> &r);
// XActiveDataSink
virtual void SAL_CALL
- setInputStream(const Reference<XInputStream>& inputStream)
+ setInputStream(const com::sun::star::uno::Reference<XInputStream>& inputStream)
throw (RuntimeException);
- virtual Reference<XInputStream> SAL_CALL
+ virtual com::sun::star::uno::Reference<XInputStream> SAL_CALL
getInputStream() throw (RuntimeException);
// XActiveDataSource
virtual void SAL_CALL
- setOutputStream(const Reference<XOutputStream>& outputStream)
+ setOutputStream(const com::sun::star::uno::Reference<XOutputStream>& outputStream)
throw (RuntimeException);
- virtual Reference<XOutputStream> SAL_CALL
+ virtual com::sun::star::uno::Reference<XOutputStream> SAL_CALL
getOutputStream() throw (RuntimeException);
// XActiveDataControl
virtual void SAL_CALL
- addListener(const Reference<XStreamListener>& listener)
+ addListener(const com::sun::star::uno::Reference<XStreamListener>& listener)
throw (RuntimeException);
virtual void SAL_CALL
- removeListener(const Reference<XStreamListener>& listener)
+ removeListener(const com::sun::star::uno::Reference<XStreamListener>& listener)
throw (RuntimeException);
virtual void SAL_CALL
start() throw (RuntimeException);
@@ -167,7 +169,7 @@ namespace XSLT
::std::map<const char*, OString> SAL_CALL
getParameters();
- virtual Reference<XMultiServiceFactory> SAL_CALL
+ virtual com::sun::star::uno::Reference<XMultiServiceFactory> SAL_CALL
getServiceFactory() {
return m_rServiceFactory;
}
@@ -179,7 +181,7 @@ namespace XSLT
* It pipes the streams provided by a LibXSLTTransformer
* instance through libxslt.
*/
- class Reader : public osl::Thread
+ class Reader : public salhelper::Thread
{
public:
Reader(LibXSLTTransformer* transformer);
@@ -192,22 +194,18 @@ namespace XSLT
int SAL_CALL
closeOutput();
- protected:
+ private:
virtual
~Reader();
- private:
static const sal_Int32 OUTPUT_BUFFER_SIZE;
static const sal_Int32 INPUT_BUFFER_SIZE;
LibXSLTTransformer* m_transformer;
- sal_Bool m_terminated;
Sequence<sal_Int8> m_readBuf;
Sequence<sal_Int8> m_writeBuf;
- virtual void SAL_CALL
- run();
- virtual void SAL_CALL
- onTerminated();
+ virtual void
+ execute();
void SAL_CALL
registerExtensionModule();
};
diff --git a/filter/source/xsltfilter/OleHandler.hxx b/filter/source/xsltfilter/OleHandler.hxx
index 8db4f88..bd6aba9 100644
--- a/filter/source/xsltfilter/OleHandler.hxx
+++ b/filter/source/xsltfilter/OleHandler.hxx
@@ -81,7 +81,7 @@ namespace XSLT
class OleHandler
{
public:
- OleHandler(const Reference<XMultiServiceFactory>& msf){
+ OleHandler(const com::sun::star::uno::Reference<XMultiServiceFactory>& msf){
m_msf =msf;
}
void SAL_CALL
@@ -90,9 +90,9 @@ namespace XSLT
getByName(const OUString& streamName);
private:
- Reference<XMultiServiceFactory> m_msf;
- Reference<XNameContainer> m_storage;
- Reference<XStream> m_rootStream;
+ com::sun::star::uno::Reference<XMultiServiceFactory> m_msf;
+ com::sun::star::uno::Reference<XNameContainer> m_storage;
+ com::sun::star::uno::Reference<XStream> m_rootStream;
void SAL_CALL
ensureCreateRootStorage();
OString SAL_CALL
@@ -101,7 +101,7 @@ namespace XSLT
insertSubStorage(const OUString& streamName, const OString& content);
void SAL_CALL
initRootStorageFromBase64(const OString& content);
- Reference<XStream> SAL_CALL
+ com::sun::star::uno::Reference<XStream> SAL_CALL
createTempFile();
};
}
diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx
index 06d4f47..687192e 100644
--- a/filter/source/xsltfilter/XSLTFilter.cxx
+++ b/filter/source/xsltfilter/XSLTFilter.cxx
@@ -93,6 +93,8 @@ using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::task;
+namespace css = com::sun::star;
+
namespace XSLT
{
/*
@@ -115,12 +117,12 @@ namespace XSLT
private:
// the UNO ServiceFactory
- Reference<XMultiServiceFactory> m_rServiceFactory;
+ css::uno::Reference<XMultiServiceFactory> m_rServiceFactory;
// DocumentHandler interface of the css::xml::sax::Writer service
- Reference<XOutputStream> m_rOutputStream;
+ css::uno::Reference<XOutputStream> m_rOutputStream;
- Reference<XActiveDataControl> m_tcontrol;
+ css::uno::Reference<XActiveDataControl> m_tcontrol;
oslCondition m_cTransformed;
sal_Bool m_bTerminated;
@@ -136,7 +138,7 @@ namespace XSLT
public:
// ctor...
- XSLTFilter(const Reference<XMultiServiceFactory> &r);
+ XSLTFilter(const css::uno::Reference<XMultiServiceFactory> &r);
// XStreamListener
virtual void SAL_CALL
@@ -152,7 +154,7 @@ namespace XSLT
// XImportFilter
virtual sal_Bool SAL_CALL
- importer(const Sequence<PropertyValue>& aSourceData, const Reference<
+ importer(const Sequence<PropertyValue>& aSourceData, const css::uno::Reference<
XDocumentHandler>& xHandler,
const Sequence<OUString>& msUserData) throw (RuntimeException);
@@ -168,7 +170,7 @@ namespace XSLT
endDocument() throw (SAXException, RuntimeException);
};
- XSLTFilter::XSLTFilter(const Reference<XMultiServiceFactory> &r):
+ XSLTFilter::XSLTFilter(const css::uno::Reference<XMultiServiceFactory> &r):
m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
{
m_cTransformed = osl_createCondition();
@@ -185,13 +187,13 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
::rtl::OUString sExpandedUrl;
try
{
- Reference<XComponentContext> xContext;
- Reference<XPropertySet> xProps(m_rServiceFactory,
+ css::uno::Reference<XComponentContext> xContext;
+ css::uno::Reference<XPropertySet> xProps(m_rServiceFactory,
UNO_QUERY_THROW);
xContext.set(xProps->getPropertyValue(::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))),
UNO_QUERY_THROW);
- Reference<XMacroExpander>
+ css::uno::Reference<XMacroExpander>
xMacroExpander(
xContext->getValueByName(
::rtl::OUString(
@@ -243,7 +245,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
XSLTFilter::rel2abs(const OUString& s)
{
- Reference<XStringSubstitution>
+ css::uno::Reference<XStringSubstitution>
subs(
m_rServiceFactory->createInstance(
OUString(
@@ -261,7 +263,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
sal_Bool
XSLTFilter::importer(const Sequence<PropertyValue>& aSourceData,
- const Reference<XDocumentHandler>& xHandler, const Sequence<
+ const css::uno::Reference<XDocumentHandler>& xHandler, const Sequence<
OUString>& msUserData) throw (RuntimeException)
{
if (msUserData.getLength() < 5)
@@ -276,8 +278,8 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
// the sax parser that drives the supplied document handler
sal_Int32 nLength = aSourceData.getLength();
OUString aName, aFileName, aURL;
- Reference<XInputStream> xInputStream;
- Reference<XInteractionHandler> xInterActionHandler;
+ css::uno::Reference<XInputStream> xInputStream;
+ css::uno::Reference<XInteractionHandler> xInterActionHandler;
for (sal_Int32 i = 0; i < nLength; i++)
{
aName = aSourceData[i].Name;
@@ -297,7 +299,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
// create SAX parser that will read the document file
// and provide events to xHandler passed to this call
- Reference<XParser>
+ css::uno::Reference<XParser>
xSaxParser(
m_rServiceFactory->createInstance(
OUString(
@@ -325,7 +327,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
if (!msUserData[1].isEmpty())
serviceName = msUserData[1];
- m_tcontrol = Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY);
+ m_tcontrol = css::uno::Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY);
OSL_ASSERT(xHandler.is());
OSL_ASSERT(xInputStream.is());
@@ -335,24 +337,24 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
try
{
// we want to be notfied when the processing is done...
- m_tcontrol->addListener(Reference<XStreamListener> (
+ m_tcontrol->addListener(css::uno::Reference<XStreamListener> (
this));
// connect input to transformer
- Reference<XActiveDataSink> tsink(m_tcontrol, UNO_QUERY);
+ css::uno::Reference<XActiveDataSink> tsink(m_tcontrol, UNO_QUERY);
tsink->setInputStream(xInputStream);
// create pipe
- Reference<XOutputStream>
+ css::uno::Reference<XOutputStream>
pipeout(
m_rServiceFactory->createInstance(
OUString(
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.Pipe" ))),
UNO_QUERY);
- Reference<XInputStream> pipein(pipeout, UNO_QUERY);
+ css::uno::Reference<XInputStream> pipein(pipeout, UNO_QUERY);
//connect transformer to pipe
- Reference<XActiveDataSource> tsource(m_tcontrol,
+ css::uno::Reference<XActiveDataSource> tsource(m_tcontrol,
UNO_QUERY);
tsource->setOutputStream(pipeout);
@@ -381,7 +383,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
Any r;
r <<= exc;
::comphelper::OInteractionRequest* pRequest = new ::comphelper::OInteractionRequest(r);
- Reference< XInteractionRequest > xRequest(pRequest);
+ css::uno::Reference< XInteractionRequest > xRequest(pRequest);
::comphelper::OInteractionRetry* pRetry = new ::comphelper::OInteractionRetry;
::comphelper::OInteractionAbort* pAbort = new ::comphelper::OInteractionAbort;
pRequest->addContinuation(pRetry);
@@ -436,7 +438,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
sal_Bool bIndent = sal_False;
OUString aDoctypePublic;
OUString aDoctypeSystem;
- // Reference<XOutputStream> rOutputStream;
+ // css::uno::Reference<XOutputStream> rOutputStream;
sal_Int32 nLength = aSourceData.getLength();
for (sal_Int32 i = 0; i < nLength; i++)
{
@@ -456,7 +458,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
if (!getDelegate().is())
{
// get the document writer
- setDelegate(Reference<XExtendedDocumentHandler> (
+ setDelegate(css::uno::Reference<XExtendedDocumentHandler> (
m_rServiceFactory->createInstance(
OUString(
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ))),
@@ -489,35 +491,35 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
if (!msUserData[1].isEmpty())
serviceName = msUserData[1];
- m_tcontrol = Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY);
+ m_tcontrol = css::uno::Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY);
OSL_ASSERT(m_rOutputStream.is());
OSL_ASSERT(m_tcontrol.is());
if (m_tcontrol.is() && m_rOutputStream.is())
{
// we want to be notfied when the processing is done...
- m_tcontrol->addListener(Reference<XStreamListener> (this));
+ m_tcontrol->addListener(css::uno::Reference<XStreamListener> (this));
// create pipe
- Reference<XOutputStream>
+ css::uno::Reference<XOutputStream>
pipeout(
m_rServiceFactory->createInstance(
OUString(
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.Pipe" ))),
UNO_QUERY);
- Reference<XInputStream> pipein(pipeout, UNO_QUERY);
+ css::uno::Reference<XInputStream> pipein(pipeout, UNO_QUERY);
// connect sax writer to pipe
- Reference<XActiveDataSource> xmlsource(getDelegate(),
+ css::uno::Reference<XActiveDataSource> xmlsource(getDelegate(),
UNO_QUERY);
xmlsource->setOutputStream(pipeout);
// connect pipe to transformer
- Reference<XActiveDataSink> tsink(m_tcontrol, UNO_QUERY);
+ css::uno::Reference<XActiveDataSink> tsink(m_tcontrol, UNO_QUERY);
tsink->setInputStream(pipein);
// connect transformer to output
- Reference<XActiveDataSource> tsource(m_tcontrol, UNO_QUERY);
+ css::uno::Reference<XActiveDataSource> tsource(m_tcontrol, UNO_QUERY);
tsource->setOutputStream(m_rOutputStream);
// we will start receiving events after returning 'true'.
@@ -568,16 +570,16 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
#define TRANSFORMER_SERVICE_NAME "com.sun.star.documentconversion.LibXSLTTransformer"
#define TRANSFORMER_IMPL_NAME "com.sun.star.comp.documentconversion.LibXSLTTransformer"
- static Reference<XInterface> SAL_CALL
- CreateTransformerInstance(const Reference<XMultiServiceFactory> &r)
+ static css::uno::Reference<XInterface> SAL_CALL
+ CreateTransformerInstance(const css::uno::Reference<XMultiServiceFactory> &r)
{
- return Reference<XInterface> ((OWeakObject *) new LibXSLTTransformer(r));
+ return css::uno::Reference<XInterface> ((OWeakObject *) new LibXSLTTransformer(r));
}
- static Reference<XInterface> SAL_CALL
- CreateFilterInstance(const Reference<XMultiServiceFactory> &r)
+ static css::uno::Reference<XInterface> SAL_CALL
+ CreateFilterInstance(const css::uno::Reference<XMultiServiceFactory> &r)
{
- return Reference<XInterface> ((OWeakObject *) new XSLTFilter(r));
+ return css::uno::Reference<XInterface> ((OWeakObject *) new XSLTFilter(r));
}
}
@@ -600,7 +602,7 @@ extern "C"
= OUString(
RTL_CONSTASCII_USTRINGPARAM( FILTER_SERVICE_NAME ));
- Reference<XSingleServiceFactory>
+ css::uno::Reference<XSingleServiceFactory>
xFactory(
createSingleFactory(
reinterpret_cast<XMultiServiceFactory *> (pServiceManager),
@@ -621,7 +623,7 @@ extern "C"
serviceNames.getArray()[0]
= OUString(
RTL_CONSTASCII_USTRINGPARAM( TRANSFORMER_SERVICE_NAME ));
- Reference<XSingleServiceFactory>
+ css::uno::Reference<XSingleServiceFactory>
xFactory(
createSingleFactory(
reinterpret_cast<XMultiServiceFactory *> (pServiceManager),
commit 8b960f0ec4ac13a98d8b1c33cf23ef82cc5b6841
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:45:37 2012 +0100
Adapted LateInitThread to safer-to-use salhelper::Thread
diff --git a/filter/Library_filterconfig.mk b/filter/Library_filterconfig.mk
index 1384780..39346e7 100644
--- a/filter/Library_filterconfig.mk
+++ b/filter/Library_filterconfig.mk
@@ -39,6 +39,7 @@ $(eval $(call gb_Library_add_linked_libs,filterconfig,\
cppuhelper \
cppu \
sal \
+ salhelper \
$(gb_STDLIBS) \
))
diff --git a/filter/prj/build.lst b/filter/prj/build.lst
index 76713fe..9083dc7 100644
--- a/filter/prj/build.lst
+++ b/filter/prj/build.lst
@@ -1,2 +1,2 @@
-fl filter : TRANSLATIONS:translations svtools unotools xmloff cppu tools cppuhelper sal svx javaunohelper XPDF:xpdf jvmaccess canvas SAXON:saxon LIBXSLT:libxslt basegfx package PYTHON:python NULL
+fl filter : TRANSLATIONS:translations svtools unotools xmloff cppu tools cppuhelper sal salhelper svx javaunohelper XPDF:xpdf jvmaccess canvas SAXON:saxon LIBXSLT:libxslt basegfx package PYTHON:python NULL
fl filter\prj nmake - all fl_prj NULL
diff --git a/filter/source/config/cache/lateinitlistener.cxx b/filter/source/config/cache/lateinitlistener.cxx
index 1179bf5..3d44922 100644
--- a/filter/source/config/cache/lateinitlistener.cxx
+++ b/filter/source/config/cache/lateinitlistener.cxx
@@ -26,15 +26,15 @@
*
************************************************************************/
+#include "sal/config.h"
+
+#include "rtl/ref.hxx"
+#include "rtl/ustring.hxx"
#include "lateinitlistener.hxx"
#include "lateinitthread.hxx"
//_______________________________________________
-// includes
-#include <rtl/ustring.hxx>
-
-//_______________________________________________
// namespace
namespace filter{
@@ -110,8 +110,11 @@ void SAL_CALL LateInitListener::notifyEvent(const css::document::EventObject& aE
if (!aEvent.EventName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("OnCloseApp")))
{
- LateInitThread* pThread = new LateInitThread();
- pThread->create();
+ rtl::Reference< LateInitThread >(new LateInitThread())->launch();
+ //TODO: a protocol is missing how to join with the launched
+ // thread before exit(3), to ensure the thread is no longer
+ // relying on any infrastructure while that infrastructure is
+ // being shut down in atexit handlers
}
}
}
diff --git a/filter/source/config/cache/lateinitthread.cxx b/filter/source/config/cache/lateinitthread.cxx
index 61c066c..80b9348 100644
--- a/filter/source/config/cache/lateinitthread.cxx
+++ b/filter/source/config/cache/lateinitthread.cxx
@@ -26,40 +26,21 @@
*
************************************************************************/
+#include "sal/config.h"
-#include "lateinitthread.hxx"
-
-//_______________________________________________
-// includes
-
-//_______________________________________________
-// namespace
-
-namespace filter{
- namespace config{
-
-namespace css = ::com::sun::star;
-
-//_______________________________________________
-// definitions
-
-
-
-LateInitThread::LateInitThread()
-{
-}
+#include "salhelper/singletonref.hxx"
+#include "filtercache.hxx"
+#include "lateinitthread.hxx"
+namespace filter { namespace config {
-LateInitThread::~LateInitThread()
-{
-}
+LateInitThread::LateInitThread(): Thread("lateinitthread") {}
+LateInitThread::~LateInitThread() {}
-
-void SAL_CALL LateInitThread::run()
-{
- // sal_True => It indicates using of this method by this thread
+void LateInitThread::execute() {
+ // true => It indicates using of this method by this thread
// The filter cache use this information to show an assertion
// for "optimization failure" in case the first calli of loadAll()
// was not this thread ...
@@ -68,16 +49,10 @@ void SAL_CALL LateInitThread::run()
// May be they show the problem of a corrupted filter
// configuration, which is handled inside our event loop or desktop.main()!
- ::salhelper::SingletonRef< FilterCache > rCache;
- rCache->load(FilterCache::E_CONTAINS_ALL, sal_True);
-}
-
-void SAL_CALL LateInitThread::onTerminated()
-{
- delete this;
+ salhelper::SingletonRef< FilterCache >()->load(
+ FilterCache::E_CONTAINS_ALL, true);
}
- } // namespace config
-} // namespace filter
+} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/config/cache/lateinitthread.hxx b/filter/source/config/cache/lateinitthread.hxx
index 98c59b0..3ade96f 100644
--- a/filter/source/config/cache/lateinitthread.hxx
+++ b/filter/source/config/cache/lateinitthread.hxx
@@ -26,26 +26,14 @@
*
************************************************************************/
-#ifndef __FILTER_CONFIG_LATEINITTHREAD_HXX_
-#define __FILTER_CONFIG_LATEINITTHREAD_HXX_
+#ifndef INCLUDED_FILTER_SOURCE_CONFIG_CACHE_LATEINITTHREAD_HXX
+#define INCLUDED_FILTER_SOURCE_CONFIG_CACHE_LATEINITTHREAD_HXX
-//_______________________________________________
-// includes
+#include "sal/config.h"
-#include "filtercache.hxx"
-#include <salhelper/singletonref.hxx>
-#include <osl/thread.hxx>
+#include "salhelper/thread.hxx"
-//_______________________________________________
-// namespace
-
-namespace filter{
- namespace config{
-
-//_______________________________________________
-// definitions
-
-//_______________________________________________
+namespace filter{ namespace config {
/** @short implements a thread, which will update the
global filter cache of an office, after its
@@ -57,38 +45,18 @@ namespace filter{
@attention The filter cache will be blocked during this thrad runs!
*/
-class LateInitThread : public ::osl::Thread
-{
- //-------------------------------------------
- // native interface
-
- public:
-
- //---------------------------------------
- // ctor/dtor
-
- /** @short initialize new instance of this class.
- */
- LateInitThread();
-
- //---------------------------------------
-
- /** @short standard dtor.
- */
- virtual ~LateInitThread();
-
- //---------------------------------------
+class LateInitThread: public salhelper::Thread {
+public:
+ LateInitThread();
- /** @short thread function.
- */
- virtual void SAL_CALL run();
+private:
+ virtual ~LateInitThread();
- virtual void SAL_CALL onTerminated();
+ virtual void execute();
};
- } // namespace config
-} // namespace filter
+} }
-#endif // __FILTER_CONFIG_LATEINITTHREAD_HXX_
+#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit d3f4ee2bc288bc3289e61354e00b40128ae98523
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:44:01 2012 +0100
Adapted SvtMatchContext_Impl to safer-to-use salhelper::Thread
diff --git a/svtools/inc/svtools/inettbc.hxx b/svtools/inc/svtools/inettbc.hxx
index f842378..9d54c68 100644
--- a/svtools/inc/svtools/inettbc.hxx
+++ b/svtools/inc/svtools/inettbc.hxx
@@ -31,6 +31,7 @@
// includes *****************************************************************
+#include "rtl/ref.hxx"
#include "svtools/svtdllapi.h"
#include <tools/string.hxx>
#include <tools/urlobj.hxx>
@@ -47,7 +48,7 @@ friend class SvtURLBox_Impl;
Link aOpenHdl;
String aBaseURL;
String aPlaceHolder;
- SvtMatchContext_Impl* pCtx;
+ rtl::Reference< SvtMatchContext_Impl > pCtx;
SvtURLBox_Impl* pImp;
INetProtocol eSmartProtocol;
sal_Bool bAutoCompleteMode : 1;
diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx
index 668a65c..7d4ffe5 100644
--- a/svtools/source/control/inettbc.cxx
+++ b/svtools/source/control/inettbc.cxx
@@ -47,7 +47,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
#include <vcl/toolbox.hxx>
-#include <osl/thread.hxx>
+#include <salhelper/thread.hxx>
#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
#include <unotools/historyoptions.hxx>
@@ -96,7 +96,7 @@ public:
}
};
-class SvtMatchContext_Impl : public ::osl::Thread
+class SvtMatchContext_Impl: public salhelper::Thread
{
static ::osl::Mutex* pDirMutex;
@@ -113,9 +113,9 @@ class SvtMatchContext_Impl : public ::osl::Thread
DECL_STATIC_LINK( SvtMatchContext_Impl, Select_Impl, void* );
- virtual void SAL_CALL onTerminated( );
- virtual void SAL_CALL run();
- virtual void SAL_CALL Cancel();
+ virtual ~SvtMatchContext_Impl();
+ virtual void execute();
+ void doExecute();
void Insert( const String& rCompletion, const String& rURL, sal_Bool bForce = sal_False);
void ReadFolder( const String& rURL, const String& rMatch, sal_Bool bSmart );
void FillPicklist(std::vector<rtl::OUString>& rPickList);
@@ -124,7 +124,6 @@ public:
static ::osl::Mutex* GetMutex();
SvtMatchContext_Impl( SvtURLBox* pBoxP, const String& rText );
- ~SvtMatchContext_Impl();
void Stop();
};
@@ -140,7 +139,8 @@ public:
SvtMatchContext_Impl::SvtMatchContext_Impl(
SvtURLBox* pBoxP, const String& rText )
- : aLink( STATIC_LINK( this, SvtMatchContext_Impl, Select_Impl ) )
+ : Thread( "SvtMatchContext_Impl" )
+ , aLink( STATIC_LINK( this, SvtMatchContext_Impl, Select_Impl ) )
, aBaseURL( pBoxP->aBaseURL )
, aText( rText )
, pBox( pBoxP )
@@ -151,8 +151,6 @@ SvtMatchContext_Impl::SvtMatchContext_Impl(
aLink.CreateMutex();
FillPicklist( aPickList );
-
- create();
}
SvtMatchContext_Impl::~SvtMatchContext_Impl()
@@ -188,22 +186,15 @@ void SvtMatchContext_Impl::FillPicklist(std::vector<rtl::OUString>& rPickList)
}
}
-void SAL_CALL SvtMatchContext_Impl::Cancel()
-{
- // Cancel button pressed
- terminate();
-}
-
void SvtMatchContext_Impl::Stop()
{
bStop = sal_True;
-
- if( isRunning() )
- terminate();
+ terminate();
}
-void SvtMatchContext_Impl::onTerminated( )
+void SvtMatchContext_Impl::execute( )
{
+ doExecute();
aLink.Call( this );
}
@@ -220,7 +211,6 @@ IMPL_STATIC_LINK( SvtMatchContext_Impl, Select_Impl, void*, )
if( pThis->bStop )
{
// completions was stopped, no display
- delete pThis;
return 0;
}
@@ -293,8 +283,7 @@ IMPL_STATIC_LINK( SvtMatchContext_Impl, Select_Impl, void*, )
// the box has this control as a member so we have to set that member
// to zero before deleting ourself.
- pBox->pCtx = NULL;
- delete pThis;
+ pBox->pCtx.clear();
return 0;
}
@@ -567,7 +556,7 @@ String SvtURLBox::ParseSmart( String aText, String aBaseURL, String aWorkDir )
}
//-------------------------------------------------------------------------
-void SvtMatchContext_Impl::run()
+void SvtMatchContext_Impl::doExecute()
{
::osl::MutexGuard aGuard( GetMutex() );
if( bStop )
@@ -750,19 +739,20 @@ void SvtURLBox::TryAutoComplete( sal_Bool bForce )
aCurText.Erase( nLen );
if( aCurText.Len() && bIsAutoCompleteEnabled )
{
- if ( pCtx )
+ if ( pCtx.is() )
{
pCtx->Stop();
- pCtx = NULL;
+ pCtx->join();
+ pCtx.clear();
}
pCtx = new SvtMatchContext_Impl( this, aCurText );
+ pCtx->launch();
}
}
//-------------------------------------------------------------------------
SvtURLBox::SvtURLBox( Window* pParent, INetProtocol eSmart )
: ComboBox( pParent , WB_DROPDOWN | WB_AUTOSIZE | WB_AUTOHSCROLL ),
- pCtx( 0 ),
eSmartProtocol( eSmart ),
bAutoCompleteMode( sal_False ),
bOnlyDirectories( sal_False ),
@@ -783,7 +773,6 @@ SvtURLBox::SvtURLBox( Window* pParent, INetProtocol eSmart )
//-------------------------------------------------------------------------
SvtURLBox::SvtURLBox( Window* pParent, WinBits _nStyle, INetProtocol eSmart )
: ComboBox( pParent, _nStyle ),
- pCtx( 0 ),
eSmartProtocol( eSmart ),
bAutoCompleteMode( sal_False ),
bOnlyDirectories( sal_False ),
@@ -799,7 +788,6 @@ SvtURLBox::SvtURLBox( Window* pParent, WinBits _nStyle, INetProtocol eSmart )
//-------------------------------------------------------------------------
SvtURLBox::SvtURLBox( Window* pParent, const ResId& _rResId, INetProtocol eSmart )
: ComboBox( pParent , _rResId ),
- pCtx( 0 ),
eSmartProtocol( eSmart ),
bAutoCompleteMode( sal_False ),
bOnlyDirectories( sal_False ),
@@ -828,10 +816,10 @@ void SvtURLBox::ImplInit()
SvtURLBox::~SvtURLBox()
{
- if( pCtx )
+ if( pCtx.is() )
{
pCtx->Stop();
- pCtx = NULL;
+ pCtx->join();
}
delete pImp;
@@ -839,15 +827,19 @@ SvtURLBox::~SvtURLBox()
void SvtURLBox::UpdatePickList( )
{
- if( pCtx )
+ if( pCtx.is() )
{
pCtx->Stop();
- pCtx = NULL;
+ pCtx->join();
+ pCtx.clear();
}
String sText = GetText();
if ( sText.Len() && bIsAutoCompleteEnabled )
+ {
pCtx = new SvtMatchContext_Impl( this, sText );
+ pCtx->launch();
+ }
}
void SvtURLBox::SetSmartProtocol( INetProtocol eProt )
@@ -927,10 +919,11 @@ void SvtURLBox::UpdatePicklistForSmartProtocol_Impl()
sal_Bool SvtURLBox::ProcessKey( const KeyCode& rKey )
{
// every key input stops the current matching thread
- if( pCtx )
+ if( pCtx.is() )
{
pCtx->Stop();
- pCtx = NULL;
+ pCtx->join();
+ pCtx.clear();
}
KeyCode aCode( rKey.GetCode() );
@@ -1068,10 +1061,11 @@ long SvtURLBox::Notify( NotifyEvent &rEvt )
{
if( !GetText().Len() )
ClearModifyFlag();
- if ( pCtx )
+ if ( pCtx.is() )
{
pCtx->Stop();
- pCtx = NULL;
+ pCtx->join();
+ pCtx.clear();
}
}
commit b5764eb9f4e95c4e77bc04e5556a7729c8de5441
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:43:29 2012 +0100
Adapted FileViewContentEnumerator to safer-to-use salhelper::Thread
diff --git a/svtools/source/contnr/contentenumeration.cxx b/svtools/source/contnr/contentenumeration.cxx
index ea846b6..9b4fdd6 100644
--- a/svtools/source/contnr/contentenumeration.cxx
+++ b/svtools/source/contnr/contentenumeration.cxx
@@ -94,7 +94,8 @@ namespace svt
const Reference< XCommandEnvironment >& _rxCommandEnv,
ContentData& _rContentToFill, ::osl::Mutex& _rContentMutex,
const IContentTitleTranslation* _pTranslator )
- :m_rContent ( _rContentToFill )
+ :Thread ( "FileViewContentEnumerator" )
+ ,m_rContent ( _rContentToFill )
,m_rContentMutex ( _rContentMutex )
,m_refCount ( 0 )
,m_xCommandEnv ( _rxCommandEnv )
@@ -142,15 +143,6 @@ namespace svt
void FileViewContentEnumerator::enumerateFolderContent(
const FolderDescriptor& _rFolder, const IUrlFilter* _pFilter, IEnumerationResultHandler* _pResultHandler )
{
- // ensure that we don't get deleted while herein
- acquire();
- // the matching "release" will be called in onTerminated
- // Note that onTerminated is only called if run was left normally.
- // If somebody terminates the thread from the outside, then onTerminated
- // will never be called. However, our terminate method is not accessible
- // to our clients, so the only class which could misbehave is this class
- // here itself ...
-
::osl::MutexGuard aGuard( m_aMutex );
m_aFolder = _rFolder;
m_pFilter = _pFilter;
@@ -159,25 +151,11 @@ namespace svt
OSL_ENSURE( m_aFolder.aContent.get().is() || m_aFolder.sURL.Len(),
"FileViewContentEnumerator::enumerateFolderContent: invalid folder descriptor!" );
- // start the thread
- create();
- }
-
- //--------------------------------------------------------------------
- oslInterlockedCount SAL_CALL FileViewContentEnumerator::acquire()
- {
- return osl_incrementInterlockedCount( &m_refCount );
- }
-
- //--------------------------------------------------------------------
- oslInterlockedCount SAL_CALL FileViewContentEnumerator::release()
- {
- if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
- {
- delete this;
- return 0;
- }
- return m_refCount;
+ launch();
+ //TODO: a protocol is missing how to join with the launched thread
+ // before exit(3), to ensure the thread is no longer relying on any
+ // infrastructure while that infrastructure is being shut down in
+ // atexit handlers
}
//--------------------------------------------------------------------
@@ -446,17 +424,11 @@ namespace svt
}
//--------------------------------------------------------------------
- void SAL_CALL FileViewContentEnumerator::run()
+ void FileViewContentEnumerator::execute()
{
enumerateFolderContent();
}
- //--------------------------------------------------------------------
- void SAL_CALL FileViewContentEnumerator::onTerminated()
- {
- release();
- }
-
//........................................................................
} // namespace svt
//........................................................................
diff --git a/svtools/source/contnr/contentenumeration.hxx b/svtools/source/contnr/contentenumeration.hxx
index 4cb8f9c..bf53373 100644
--- a/svtools/source/contnr/contentenumeration.hxx
+++ b/svtools/source/contnr/contentenumeration.hxx
@@ -33,7 +33,7 @@
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/document/XStandaloneDocumentInfo.hpp>
/** === end UNO includes === **/
-#include <osl/thread.hxx>
+#include <salhelper/thread.hxx>
#include <rtl/ref.hxx>
#include <ucbhelper/content.hxx>
#include <rtl/ustring.hxx>
@@ -185,9 +185,7 @@ namespace svt
//====================================================================
//= FileViewContentEnumerator
//====================================================================
- class FileViewContentEnumerator
- :public ::rtl::IReference
- ,private ::osl::Thread
+ class FileViewContentEnumerator: public salhelper::Thread
{
public:
typedef ::std::vector< SortingData_Impl* > ContentData;
@@ -261,13 +259,6 @@ namespace svt
*/
void cancel();
- // IReference overridables
- virtual oslInterlockedCount SAL_CALL acquire();
- virtual oslInterlockedCount SAL_CALL release();
-
- using Thread::operator new;
- using Thread::operator delete;
-
protected:
~FileViewContentEnumerator();
@@ -275,8 +266,7 @@ namespace svt
EnumerationResult enumerateFolderContent();
// Thread overridables
- virtual void SAL_CALL run();
- virtual void SAL_CALL onTerminated();
+ virtual void execute();
private:
sal_Bool implGetDocTitle( const ::rtl::OUString& _rTargetURL, ::rtl::OUString& _rRet ) const;
diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx
index 7fdc9fa..495d86b 100644
--- a/svtools/source/contnr/fileview.cxx
+++ b/svtools/source/contnr/fileview.cxx
@@ -1865,10 +1865,10 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl(
if ( ::svt::SUCCESS == eResult )
{
implEnumerationSuccess();
- m_pContentEnumerator = NULL;
+ m_pContentEnumerator.clear();
return eSuccess;
}
- m_pContentEnumerator = NULL;
+ m_pContentEnumerator.clear();
return eFailure;
}
@@ -2126,7 +2126,7 @@ void SvtFileView_Impl::CancelRunningAsyncAction()
m_pContentEnumerator->cancel();
m_bRunningAsyncAction = false;
- m_pContentEnumerator = NULL;
+ m_pContentEnumerator.clear();
if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() )
m_pCancelAsyncTimer->stop();
m_pCancelAsyncTimer = NULL;
@@ -2156,7 +2156,7 @@ void SvtFileView_Impl::enumerationDone( ::svt::EnumerationResult _eResult )
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( maMutex );
- m_pContentEnumerator = NULL;
+ m_pContentEnumerator.clear();
if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() )
m_pCancelAsyncTimer->stop();
m_pCancelAsyncTimer = NULL;
commit 2eaa1422a032d6a7ffc72a2abeb3dd3e6248a263
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:37:09 2012 +0100
Adapted AsyncEventNotifier to safer-to-use salhelper::Thread
diff --git a/comphelper/Library_comphelp.mk b/comphelper/Library_comphelp.mk
index 2b37596..71ef2a0 100644
--- a/comphelper/Library_comphelp.mk
+++ b/comphelper/Library_comphelp.mk
@@ -42,9 +42,10 @@ $(eval $(call gb_Library_add_defs,comphelper,\
))
$(eval $(call gb_Library_add_linked_libs,comphelper,\
- sal \
- cppuhelper \
cppu \
+ cppuhelper \
+ sal \
+ salhelper \
ucbhelper \
$(gb_STDLIBS) \
))
diff --git a/comphelper/inc/comphelper/asyncnotification.hxx b/comphelper/inc/comphelper/asyncnotification.hxx
index e7d5ac3..0ca35a3 100644
--- a/comphelper/inc/comphelper/asyncnotification.hxx
+++ b/comphelper/inc/comphelper/asyncnotification.hxx
@@ -29,12 +29,13 @@
#ifndef COMPHELPER_ASYNCNOTIFICATION_HXX
#define COMPHELPER_ASYNCNOTIFICATION_HXX
-#include <osl/thread.hxx>
-#include <rtl/ref.hxx>
-#include <comphelper/comphelperdllapi.h>
-#include <rtl/alloc.h>
+#include "sal/config.h"
-#include <memory>
+#include "boost/scoped_ptr.hpp"
+#include "comphelper/comphelperdllapi.h"
+#include "rtl/ref.hxx"
+#include "sal/types.h"
+#include "salhelper/thread.hxx"
//........................................................................
namespace comphelper
@@ -109,26 +110,25 @@ namespace comphelper
events in the queue. As soon as you add an event, the thread is woken up, processes the event,
and sleeps again.
*/
- class COMPHELPER_DLLPUBLIC AsyncEventNotifier :public ::osl::Thread
- ,public ::rtl::IReference
+ class COMPHELPER_DLLPUBLIC AsyncEventNotifier: public salhelper::Thread
{
friend struct EventNotifierImpl;
private:
- ::std::auto_ptr< EventNotifierImpl > m_pImpl;
+ boost::scoped_ptr< EventNotifierImpl > m_pImpl;
+
+ SAL_DLLPRIVATE virtual ~AsyncEventNotifier();
// Thread
- virtual void SAL_CALL run();
- virtual void SAL_CALL onTerminated();
+ SAL_DLLPRIVATE virtual void execute();
public:
/** constructs a notifier thread
- */
- AsyncEventNotifier();
- // IReference implementations
- virtual oslInterlockedCount SAL_CALL acquire();
- virtual oslInterlockedCount SAL_CALL release();
+ @param name the thread name, see ::osl_setThreadName; must not be
+ null
+ */
+ AsyncEventNotifier(char const * name);
/** terminates the thread
@@ -156,9 +156,6 @@ namespace comphelper
/** removes all events for the given event processor from the queue
*/
void removeEventsForProcessor( const ::rtl::Reference< IEventProcessor >& _xProcessor );
-
- protected:
- virtual ~AsyncEventNotifier();
};
//====================================================================
diff --git a/comphelper/prj/build.lst b/comphelper/prj/build.lst
index 722ac81..007c047 100644
--- a/comphelper/prj/build.lst
+++ b/comphelper/prj/build.lst
@@ -1,2 +1,2 @@
-ph comphelper : cppuhelper ucbhelper offapi officecfg salhelper LIBXSLT:libxslt NULL
+ch comphelper : BOOST:boost cppuhelper ucbhelper offapi officecfg salhelper LIBXSLT:libxslt NULL
ch comphelper\prj nmake - all ch_all NULL
diff --git a/comphelper/source/misc/asyncnotification.cxx b/comphelper/source/misc/asyncnotification.cxx
index cf8b628..216cdb2 100644
--- a/comphelper/source/misc/asyncnotification.cxx
+++ b/comphelper/source/misc/asyncnotification.cxx
@@ -142,8 +142,8 @@ namespace comphelper
//= AsyncEventNotifier
//====================================================================
//--------------------------------------------------------------------
- AsyncEventNotifier::AsyncEventNotifier()
- :m_pImpl( new EventNotifierImpl )
+ AsyncEventNotifier::AsyncEventNotifier(char const * name):
+ Thread(name), m_pImpl(new EventNotifierImpl)
{
}
@@ -191,13 +191,8 @@ namespace comphelper
}
//--------------------------------------------------------------------
- void AsyncEventNotifier::run()
+ void AsyncEventNotifier::execute()
{
- acquire();
-
- // keep us alive, in case we're terminated in the mid of the following
- ::rtl::Reference< AsyncEventNotifier > xKeepAlive( this );
-
do
{
AnyEventRef aNextEvent;
@@ -248,32 +243,6 @@ namespace comphelper
while ( sal_True );
}
- //--------------------------------------------------------------------
- void SAL_CALL AsyncEventNotifier::onTerminated()
- {
- Thread::onTerminated();
- // when we were started (->run), we aquired ourself. Release this now
- // that we were finally terminated
- release();
- }
-
- //--------------------------------------------------------------------
- oslInterlockedCount SAL_CALL AsyncEventNotifier::acquire()
- {
- return osl_incrementInterlockedCount( &m_pImpl->m_refCount );
- }
-
- //--------------------------------------------------------------------
- oslInterlockedCount SAL_CALL AsyncEventNotifier::release()
- {
- if ( 0 == osl_decrementInterlockedCount( &m_pImpl->m_refCount ) )
- {
- delete this;
- return 0;
- }
- return m_pImpl->m_refCount;
- }
-
//........................................................................
} // namespace comphelper
//........................................................................
diff --git a/dbaccess/source/core/dataaccess/documenteventnotifier.cxx b/dbaccess/source/core/dataaccess/documenteventnotifier.cxx
index 24a46a2..2b7cf9b 100644
--- a/dbaccess/source/core/dataaccess/documenteventnotifier.cxx
+++ b/dbaccess/source/core/dataaccess/documenteventnotifier.cxx
@@ -166,7 +166,7 @@ namespace dbaccess
m_pEventBroadcaster->removeEventsForProcessor( this );
m_pEventBroadcaster->terminate();
m_pEventBroadcaster->join();
- m_pEventBroadcaster = NULL;
+ m_pEventBroadcaster.clear();
}
lang::EventObject aEvent( m_rDocument );
@@ -190,7 +190,7 @@ namespace dbaccess
m_bInitialized = true;
if ( m_pEventBroadcaster.is() )
// there are already pending asynchronous events
- m_pEventBroadcaster->create();
+ m_pEventBroadcaster->launch();
}
void DocumentEventNotifier_Impl::impl_notifyEvent_nothrow( const DocumentEvent& _rEvent )
@@ -220,11 +220,12 @@ namespace dbaccess
{
if ( !m_pEventBroadcaster.is() )
{
- m_pEventBroadcaster.set( new ::comphelper::AsyncEventNotifier );
+ m_pEventBroadcaster.set(
+ new ::comphelper::AsyncEventNotifier("DocumentEventNotifier"));
if ( m_bInitialized )
// start processing the events if and only if we (our document, respectively) are
// already initialized
- m_pEventBroadcaster->create();
+ m_pEventBroadcaster->launch();
}
m_pEventBroadcaster->addEvent( new DocumentEventHolder( _rEvent ), this );
}
diff --git a/extensions/Library_pcr.mk b/extensions/Library_pcr.mk
index 857258d..2a32152 100644
--- a/extensions/Library_pcr.mk
+++ b/extensions/Library_pcr.mk
@@ -57,6 +57,7 @@ $(eval $(call gb_Library_add_linked_libs,pcr,\
cppuhelper \
cppu \
sal \
+ salhelper \
$(gb_STDLIBS) \
))
diff --git a/extensions/prj/build.lst b/extensions/prj/build.lst
index 06f2e2d..90e646a 100644
--- a/extensions/prj/build.lst
+++ b/extensions/prj/build.lst
@@ -1,4 +1,4 @@
-ex extensions : officecfg TRANSLATIONS:translations DESKTOP:rdbmaker svx SANE:sane TWAIN:twain np_sdk offapi stoc ZLIB:zlib CURL:curl LIBXSLT:libxslt CPPUNIT:cppunit NULL
+ex extensions : officecfg salhelper TRANSLATIONS:translations DESKTOP:rdbmaker svx SANE:sane TWAIN:twain np_sdk offapi stoc ZLIB:zlib CURL:curl LIBXSLT:libxslt CPPUNIT:cppunit NULL
ex extensions\prj nmake - all ex_prj NULL
# Fails at the moment
diff --git a/extensions/source/propctrlr/browserlistbox.cxx b/extensions/source/propctrlr/browserlistbox.cxx
index 0abddac..ec907ab 100644
--- a/extensions/source/propctrlr/browserlistbox.cxx
+++ b/extensions/source/propctrlr/browserlistbox.cxx
@@ -126,8 +126,13 @@ namespace pcr
::osl::MutexGuard aGuard( getMutex() );
if ( !s_pNotifier.is() )
{
- s_pNotifier.set( new ::comphelper::AsyncEventNotifier );
- s_pNotifier->create();
+ s_pNotifier.set(
+ new ::comphelper::AsyncEventNotifier("browserlistbox"));
+ s_pNotifier->launch();
+ //TODO: a protocol is missing how to join with the launched
+ // thread before exit(3), to ensure the thread is no longer
+ // relying on any infrastructure while that infrastructure is
+ // being shut down in atexit handlers
}
return s_pNotifier;
}
diff --git a/forms/Library_frm.mk b/forms/Library_frm.mk
index f6558ef..f38dd3b 100644
--- a/forms/Library_frm.mk
+++ b/forms/Library_frm.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_linked_libs,frm,\
editeng \
i18nisolang1 \
sal \
+ salhelper \
sfx \
svl \
svt \
diff --git a/forms/prj/build.lst b/forms/prj/build.lst
index 131e8e4..599b6c7 100644
--- a/forms/prj/build.lst
+++ b/forms/prj/build.lst
@@ -1,4 +1,4 @@
-fm forms : TRANSLATIONS:translations oovbaapi svx sfx2 QADEVOOO:qadevOOo LIBXSLT:libxslt NULL
+fm forms : TRANSLATIONS:translations oovbaapi salhelper svx sfx2 QADEVOOO:qadevOOo LIBXSLT:libxslt NULL
fm forms usr1 - all fm_mkofrm NULL
fm forms\prj nmake - all fm_prj NULL
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index eb8c6c9..5dbf8a8 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -1528,7 +1528,6 @@ namespace frm
:OBoundControl( _rxFactory, VCL_CONTROL_LISTBOX, sal_False )
,m_aChangeListeners( m_aMutex )
,m_aItemListeners( m_aMutex )
- ,m_pItemBroadcaster( NULL )
{
DBG_CTOR(OListBoxControl,NULL);
@@ -1614,8 +1613,9 @@ namespace frm
{
if ( !m_pItemBroadcaster.is() )
{
- m_pItemBroadcaster.set( new ::comphelper::AsyncEventNotifier );
- m_pItemBroadcaster->create();
+ m_pItemBroadcaster.set(
+ new ::comphelper::AsyncEventNotifier("ListBox"));
+ m_pItemBroadcaster->launch();
}
m_pItemBroadcaster->addEvent( new ItemEventDescription( _rEvent ), this );
}
@@ -1701,15 +1701,20 @@ namespace frm
m_aChangeListeners.disposeAndClear( aEvent );
m_aItemListeners.disposeAndClear( aEvent );
+ rtl::Reference< comphelper::AsyncEventNotifier > t;
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_pItemBroadcaster.is() )
{
+ t = m_pItemBroadcaster;
m_pItemBroadcaster->removeEventsForProcessor( this );
m_pItemBroadcaster->terminate();
m_pItemBroadcaster = NULL;
}
}
+ if (t.is()) {
+ t->join();
+ }
OBoundControl::disposing();
}
commit 40d21ab3c75a7c18de940162563015ae80136709
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:31:56 2012 +0100
Adapted OfficeIPCThread to safer-to-use salhelper::Thread
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 6880eec..15acbb1 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -53,6 +53,7 @@ $(eval $(call gb_Library_add_linked_libs,sofficeapp,\
deploymentmisc \
i18nisolang1 \
sal \
+ salhelper \
sfx \
svl \
svt \
diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst
index 3d8cb8b..b86555c 100644
--- a/desktop/prj/build.lst
+++ b/desktop/prj/build.lst
@@ -1,3 +1,3 @@
-dt desktop : TRANSLATIONS:translations sfx2 stoc BERKELEYDB:berkeleydb sysui BOOST:boost svx DESKTOP:xmlhelp sal unoil officecfg offapi filter LIBXSLT:libxslt NULL
+dt desktop : TRANSLATIONS:translations sfx2 stoc BERKELEYDB:berkeleydb sysui BOOST:boost svx DESKTOP:xmlhelp sal salhelper unoil officecfg offapi filter LIBXSLT:libxslt NULL
dt desktop usr1 - all dt_mkout NULL
dt desktop\prj nmake - all dt_prj NULL
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 2cb4e6c..a0d2f3f 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -220,7 +220,7 @@ bool addArgument(rtl::OStringBuffer &rArguments, char prefix,
}
-OfficeIPCThread* OfficeIPCThread::pGlobalOfficeIPCThread = 0;
+rtl::Reference< OfficeIPCThread > OfficeIPCThread::pGlobalOfficeIPCThread;
namespace { struct Security : public rtl::Static<osl::Security, Security> {}; }
// Turns a string in aMsg such as file:///home/foo/.libreoffice/3
@@ -376,7 +376,7 @@ void OfficeIPCThread::SetDowning()
// requests are executed anymore.
::osl::MutexGuard aGuard( GetMutex() );
- if ( pGlobalOfficeIPCThread )
+ if ( pGlobalOfficeIPCThread.is() )
pGlobalOfficeIPCThread->mbDowning = true;
}
@@ -387,7 +387,7 @@ void OfficeIPCThread::EnableRequests( bool i_bEnable )
// switch between just queueing the requests and executing them
::osl::MutexGuard aGuard( GetMutex() );
- if ( pGlobalOfficeIPCThread )
+ if ( pGlobalOfficeIPCThread.is() )
{
s_bInEnableRequests = true;
pGlobalOfficeIPCThread->mbRequestsEnabled = i_bEnable;
@@ -406,7 +406,7 @@ sal_Bool OfficeIPCThread::AreRequestsPending()
{
// Give info about pending requests
::osl::MutexGuard aGuard( GetMutex() );
- if ( pGlobalOfficeIPCThread )
+ if ( pGlobalOfficeIPCThread.is() )
return ( pGlobalOfficeIPCThread->mnPendingRequests > 0 );
else
return sal_False;
@@ -416,7 +416,7 @@ void OfficeIPCThread::RequestsCompleted( int nCount )
{
// Remove nCount pending requests from our internal counter
::osl::MutexGuard aGuard( GetMutex() );
- if ( pGlobalOfficeIPCThread )
+ if ( pGlobalOfficeIPCThread.is() )
{
if ( pGlobalOfficeIPCThread->mnPendingRequests > 0 )
pGlobalOfficeIPCThread->mnPendingRequests -= nCount;
@@ -427,13 +427,13 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
{
::osl::MutexGuard aGuard( GetMutex() );
- if( pGlobalOfficeIPCThread )
+ if( pGlobalOfficeIPCThread.is() )
return IPC_STATUS_OK;
::rtl::OUString aUserInstallPath;
::rtl::OUString aDummy;
- OfficeIPCThread* pThread = new OfficeIPCThread;
+ rtl::Reference< OfficeIPCThread > pThread(new OfficeIPCThread);
pThread->maPipeIdent = OUString( RTL_CONSTASCII_USTRINGPARAM( "SingleOfficeIPC_" ) );
@@ -444,7 +444,6 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
aDummy = aUserInstallPath;
else
{
- delete pThread;
return IPC_STATUS_BOOTSTRAP_ERROR;
}
@@ -530,7 +529,7 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
{
// Seems we are the one and only, so start listening thread
pGlobalOfficeIPCThread = pThread;
- pThread->create(); // starts thread
+ pThread->launch();
}
else
{
@@ -562,7 +561,6 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
int n = aStreamPipe.read( aReceiveBuffer, aToken.Len() );
aReceiveBuffer[n]='\0';
- delete pThread;
if (aToken.CompareTo(aReceiveBuffer)!= COMPARE_EQUAL) {
// something went wrong
delete[] aReceiveBuffer;
@@ -580,10 +578,11 @@ void OfficeIPCThread::DisableOfficeIPCThread()
{
osl::ClearableMutexGuard aMutex( GetMutex() );
- if( pGlobalOfficeIPCThread )
+ if( pGlobalOfficeIPCThread.is() )
{
- OfficeIPCThread *pOfficeIPCThread = pGlobalOfficeIPCThread;
- pGlobalOfficeIPCThread = 0;
+ rtl::Reference< OfficeIPCThread > pOfficeIPCThread(
+ pGlobalOfficeIPCThread);
+ pGlobalOfficeIPCThread.clear();
// send thread a termination message
// this is done so the subsequent join will not hang
@@ -605,13 +604,11 @@ void OfficeIPCThread::DisableOfficeIPCThread()
// exit gracefully and join
pOfficeIPCThread->join();
- delete pOfficeIPCThread;
-
-
}
}
OfficeIPCThread::OfficeIPCThread() :
+ Thread( "OfficeIPCThread" ),
mbDowning( false ),
mbRequestsEnabled( false ),
mnPendingRequests( 0 ),
@@ -627,7 +624,7 @@ OfficeIPCThread::~OfficeIPCThread()
mpDispatchWatcher->release();
maPipe.close();
maStreamPipe.close();
- pGlobalOfficeIPCThread = 0;
+ pGlobalOfficeIPCThread.clear();
}
static void AddURLToStringList( const rtl::OUString& aURL, rtl::OUString& aStringList )
@@ -639,16 +636,18 @@ static void AddURLToStringList( const rtl::OUString& aURL, rtl::OUString& aStrin
aStringList = aStringListBuf.makeStringAndClear();
}
-void OfficeIPCThread::SetReady(OfficeIPCThread* pThread)
+void OfficeIPCThread::SetReady(
+ rtl::Reference< OfficeIPCThread > const & pThread)
{
- if (pThread == NULL) pThread = pGlobalOfficeIPCThread;
- if (pThread != NULL)
+ rtl::Reference< OfficeIPCThread > const & t(
+ pThread.is() ? pThread : pGlobalOfficeIPCThread);
+ if (t.is())
{
- pThread->cReady.set();
+ t->cReady.set();
}
}
-void SAL_CALL OfficeIPCThread::run()
+void OfficeIPCThread::execute()
{
do
{
@@ -664,7 +663,7 @@ void SAL_CALL OfficeIPCThread::run()
cReady.wait();
// we might have decided to shutdown while we were sleeping
- if (!pGlobalOfficeIPCThread) return;
+ if (!pGlobalOfficeIPCThread.is()) return;
// only lock the mutex when processing starts, othewise we deadlock when the office goes
// down during wait
@@ -894,7 +893,7 @@ void SAL_CALL OfficeIPCThread::run()
TimeValue tval;
tval.Seconds = 1;
tval.Nanosec = 0;
- wait( tval );
+ osl::Thread::wait( tval );
}
} while( schedule() );
}
@@ -997,7 +996,7 @@ sal_Bool OfficeIPCThread::ExecuteCmdLineRequests( ProcessDocumentsRequest& aRequ
AddConversionsToDispatchList( aDispatchList, aRequest.aCwdUrl, aRequest.aConversionList, aRequest.aConversionParams, aRequest.aPrinterName, aRequest.aModule, aRequest.aConversionOut );
sal_Bool bShutdown( sal_False );
- if ( pGlobalOfficeIPCThread )
+ if ( pGlobalOfficeIPCThread.is() )
{
if( ! pGlobalOfficeIPCThread->AreRequestsEnabled() )
return bShutdown;
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index a1fe4c5..8dfda83 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -34,10 +34,11 @@
#include <osl/pipe.hxx>
#include <osl/security.hxx>
#include <osl/signal.h>
+#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
#include <cppuhelper/implbase2.hxx>
#include <osl/conditn.hxx>
-#include <osl/thread.hxx>
+#include <salhelper/thread.hxx>
#include "boost/optional.hpp"
namespace desktop
@@ -70,10 +71,10 @@ struct ProcessDocumentsRequest
};
class DispatchWatcher;
-class OfficeIPCThread : public osl::Thread
+class OfficeIPCThread : public salhelper::Thread
{
private:
- static OfficeIPCThread* pGlobalOfficeIPCThread;
+ static rtl::Reference< OfficeIPCThread > pGlobalOfficeIPCThread;
osl::Pipe maPipe;
osl::StreamPipe maStreamPipe;
@@ -101,9 +102,10 @@ class OfficeIPCThread : public osl::Thread
OfficeIPCThread();
- protected:
+ virtual ~OfficeIPCThread();
+
/// Working method which should be overridden
- virtual void SAL_CALL run();
+ virtual void execute();
public:
enum Status
@@ -113,8 +115,6 @@ class OfficeIPCThread : public osl::Thread
IPC_STATUS_BOOTSTRAP_ERROR
};
- virtual ~OfficeIPCThread();
-
// controlling pipe communication during shutdown
static void SetDowning();
static void EnableRequests( bool i_bEnable = true );
@@ -126,7 +126,9 @@ class OfficeIPCThread : public osl::Thread
static Status EnableOfficeIPCThread();
static void DisableOfficeIPCThread();
// start dispatching events...
- static void SetReady(OfficeIPCThread* pThread = NULL);
+ static void SetReady(
+ rtl::Reference< OfficeIPCThread > const & pThread =
+ rtl::Reference< OfficeIPCThread >());
bool AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; }
};
commit e4c7862ba289cc11b88f6059517fff091ab074f7
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:31:16 2012 +0100
Adapted SearchThread/TakeThread to safer-to-use salhelper::Thread
diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index 516c68c..611c858 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_Library_add_linked_libs,cui,\
jvmfwk \
lng \
sal \
+ salhelper \
sax \
sb \
sfx \
diff --git a/cui/prj/build.lst b/cui/prj/build.lst
index 958e6ca..de2687b 100644
--- a/cui/prj/build.lst
+++ b/cui/prj/build.lst
@@ -1,3 +1,3 @@
-cu cui : svx sax NULL
+cu cui : salhelper sax svx NULL
cu cui usr1 - all cui_mkout NULL
cu cui\prj nmake - all cui_prj NULL
diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx
index ba84162..3cfb82d 100644
--- a/cui/source/dialogs/cuigaldlg.cxx
+++ b/cui/source/dialogs/cuigaldlg.cxx
@@ -26,7 +26,11 @@
*
************************************************************************/
+#include "sal/config.h"
+
#include <algorithm>
+#include <cassert>
+
#include <ucbhelper/content.hxx>
#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
@@ -83,6 +87,7 @@ using namespace ::com::sun::star::uno;
SearchThread::SearchThread( SearchProgress* pProgess,
TPGalleryThemeProperties* pBrowser,
const INetURLObject& rStartURL ) :
+ Thread ( "cuiSearchThread" ),
mpProgress ( pProgess ),
mpBrowser ( pBrowser ),
maStartURL ( rStartURL )
@@ -97,7 +102,7 @@ SearchThread::~SearchThread()
// ------------------------------------------------------------------------
-void SAL_CALL SearchThread::run()
+void SearchThread::execute()
{
const String aFileType( mpBrowser->aCbbFileType.GetText() );
@@ -120,12 +125,7 @@ void SAL_CALL SearchThread::run()
ImplSearch( maStartURL, aFormats, mpBrowser->bSearchRecursive );
}
-}
-// ------------------------------------------------------------------------
-
-void SAL_CALL SearchThread::onTerminated()
-{
Application::PostUserEvent( LINK( mpProgress, SearchProgress, CleanUpHdl ) );
}
@@ -227,7 +227,7 @@ SearchProgress::SearchProgress( Window* pParent, const INetURLObject& rStartURL
aFtSearchType ( this, CUI_RES( FT_SEARCH_TYPE ) ),
aFLSearchType ( this, CUI_RES( FL_SEARCH_TYPE ) ),
aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
- maSearchThread ( this, (TPGalleryThemeProperties*) pParent, rStartURL )
+ parent_(pParent), startUrl_(rStartURL)
{
FreeResource();
aBtnCancel.SetClickHdl( LINK( this, SearchProgress, ClickCancelBtn ) );
@@ -237,7 +237,10 @@ SearchProgress::SearchProgress( Window* pParent, const INetURLObject& rStartURL
void SearchProgress::Terminate()
{
- maSearchThread.terminate();
+ if (maSearchThread.is()) {
+ maSearchThread->terminate();
+ maSearchThread->join();
+ }
}
// ------------------------------------------------------------------------
@@ -271,7 +274,10 @@ short SearchProgress::Execute()
void SearchProgress::StartExecuteModal( const Link& rEndDialogHdl )
{
- maSearchThread.create();
+ assert(!maSearchThread.is());
+ maSearchThread = new SearchThread(
+ this, static_cast< TPGalleryThemeProperties * >(parent_), startUrl_);
+ maSearchThread->launch();
ModalDialog::StartExecuteModal( rEndDialogHdl );
}
@@ -284,6 +290,7 @@ TakeThread::TakeThread(
TPGalleryThemeProperties* pBrowser,
TokenList_impl& rTakenList
) :
+ Thread ( "cuiTakeThread" ),
mpProgress ( pProgess ),
mpBrowser ( pBrowser ),
mrTakenList ( rTakenList )
@@ -298,7 +305,7 @@ TakeThread::~TakeThread()
// ------------------------------------------------------------------------
-void SAL_CALL TakeThread::run()
+void TakeThread::execute()
{
String aName;
INetURLObject aURL;
@@ -341,12 +348,7 @@ void SAL_CALL TakeThread::run()
pThm->UnlockBroadcaster();
delete pStatusProgress;
}
-}
-
-// ------------------------------------------------------------------------
-void SAL_CALL TakeThread::onTerminated()
-{
Application::PostUserEvent( LINK( mpProgress, TakeProgress, CleanUpHdl ) );
}
@@ -359,8 +361,7 @@ TakeProgress::TakeProgress( Window* pWindow ) :
aFtTakeFile ( this, CUI_RES( FT_TAKE_FILE ) ),
aFLTakeProgress( this, CUI_RES( FL_TAKE_PROGRESS ) ),
aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
- maTakeThread ( this, (TPGalleryThemeProperties*) pWindow, maTakenList )
-
+ window_(pWindow)
{
FreeResource();
aBtnCancel.SetClickHdl( LINK( this, TakeProgress, ClickCancelBtn ) );
@@ -371,7 +372,10 @@ TakeProgress::TakeProgress( Window* pWindow ) :
void TakeProgress::Terminate()
{
- maTakeThread.terminate();
+ if (maTakeThread.is()) {
+ maTakeThread->terminate();
+ maTakeThread->join();
+ }
}
// ------------------------------------------------------------------------
@@ -449,7 +453,10 @@ short TakeProgress::Execute()
void TakeProgress::StartExecuteModal( const Link& rEndDialogHdl )
{
- maTakeThread.create();
+ assert(!maTakeThread.is());
+ maTakeThread = new TakeThread(
+ this, static_cast< TPGalleryThemeProperties * >(window_), maTakenList);
+ maTakeThread->launch();
ModalDialog::StartExecuteModal( rEndDialogHdl );
}
diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx
index 8add0f8..15742ac 100644
--- a/cui/source/inc/cuigaldlg.hxx
+++ b/cui/source/inc/cuigaldlg.hxx
@@ -29,7 +29,9 @@
#ifndef _CUI_GALDLG_HXX_
#define _CUI_GALDLG_HXX_
-#include <osl/thread.hxx>
+#include "sal/config.h"
+
+#include <salhelper/thread.hxx>
#include <vcl/dialog.hxx>
#include <vcl/graph.hxx>
#include <vcl/fixed.hxx>
@@ -75,7 +77,7 @@ struct FilterEntry
// - SearchThread -
// ----------------
-class SearchThread : public ::osl::Thread
+class SearchThread: public salhelper::Thread
{
private:
@@ -87,15 +89,14 @@ private:
const ::std::vector< String >& rFormats,
sal_Bool bRecursive );
- virtual void SAL_CALL run();
- virtual void SAL_CALL onTerminated();
+ virtual ~SearchThread();
+ virtual void execute();
public:
SearchThread( SearchProgress* pProgess,
TPGalleryThemeProperties* pBrowser,
const INetURLObject& rStartURL );
- virtual ~SearchThread();
};
// ------------------
@@ -111,7 +112,9 @@ private:
FixedText aFtSearchType;
FixedLine aFLSearchType;
CancelButton aBtnCancel;
- SearchThread maSearchThread;
+ Window * parent_;
+ INetURLObject startUrl_;
+ rtl::Reference< SearchThread > maSearchThread;
DECL_LINK( ClickCancelBtn, void* );
void Terminate();
@@ -132,7 +135,7 @@ public:
// - TakeThread -
// --------------
-class TakeThread : public ::osl::Thread
+class TakeThread: public salhelper::Thread
{
private:
@@ -140,8 +143,8 @@ private:
TPGalleryThemeProperties* mpBrowser;
TokenList_impl& mrTakenList;
- virtual void SAL_CALL run();
- virtual void SAL_CALL onTerminated();
+ virtual ~TakeThread();
+ virtual void execute();
public:
@@ -150,7 +153,6 @@ public:
TPGalleryThemeProperties* pBrowser,
TokenList_impl& rTakenList
);
- virtual ~TakeThread();
};
// ----------------
@@ -164,7 +166,8 @@ private:
FixedText aFtTakeFile;
FixedLine aFLTakeProgress;
CancelButton aBtnCancel;
- TakeThread maTakeThread;
+ Window * window_;
+ rtl::Reference< TakeThread > maTakeThread;
TokenList_impl maTakenList;
DECL_LINK( ClickCancelBtn, void* );
commit 97355467b403d2277e65a8582ab63ce8fb002806
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:30:41 2012 +0100
Adapted WriteThread to safer-to-use salhelper::Thread
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index a44f07c..0e1c7e4 100644
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -48,7 +48,6 @@
#include "osl/conditn.hxx"
#include "osl/file.hxx"
#include "osl/mutex.hxx"
-#include "osl/thread.hxx"
#include "rtl/bootstrap.hxx"
#include "rtl/logfile.h"
#include "rtl/oustringostreaminserter.hxx"
@@ -59,7 +58,7 @@
#include "rtl/instance.hxx"
#include "sal/log.hxx"
#include "sal/types.h"
-#include "salhelper/simplereferenceobject.hxx"
+#include "salhelper/thread.hxx"
#include "additions.hxx"
#include "components.hxx"
@@ -154,16 +153,8 @@ bool canRemoveFromLayer(int layer, rtl::Reference< Node > const & node) {
}
-class Components::WriteThread:
- public osl::Thread, public salhelper::SimpleReferenceObject
-{
+class Components::WriteThread: public salhelper::Thread {
public:
- static void * operator new(std::size_t size)
- { return Thread::operator new(size); }
-
- static void operator delete(void * pointer)
- { Thread::operator delete(pointer); }
-
WriteThread(
rtl::Reference< WriteThread > * reference, Components & components,
rtl::OUString const & url, Data const & data);
@@ -173,9 +164,7 @@ public:
private:
virtual ~WriteThread() {}
- virtual void SAL_CALL run();
-
- virtual void SAL_CALL onTerminated() { release(); }
+ virtual void execute();
rtl::Reference< WriteThread > * reference_;
Components & components_;
@@ -188,14 +177,14 @@ private:
Components::WriteThread::WriteThread(
rtl::Reference< WriteThread > * reference, Components & components,
rtl::OUString const & url, Data const & data):
- reference_(reference), components_(components), url_(url), data_(data)
+ Thread("configmgrWriter"), reference_(reference), components_(components),
+ url_(url), data_(data)
{
lock_ = lock();
assert(reference != 0);
- acquire();
}
-void Components::WriteThread::run() {
+void Components::WriteThread::execute() {
TimeValue t = { 1, 0 }; // 1 sec
delay_.wait(&t); // must not throw; result_error is harmless and ignored
osl::MutexGuard g(*lock_); // must not throw
@@ -310,7 +299,7 @@ void Components::writeModifications() {
if (!writeThread_.is()) {
writeThread_ = new WriteThread(
&writeThread_, *this, modificationFileUrl_, data_);
- writeThread_->create();
+ writeThread_->launch();
}
}
commit d21fb1451e7260e179b90ed95664f9bebb67eed1
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:30:08 2012 +0100
Adapted Reader/Writer to safer-to-use salhelper::Thread
diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx
index a47f14e..fec485d 100644
--- a/binaryurp/source/bridge.cxx
+++ b/binaryurp/source/bridge.cxx
@@ -106,7 +106,7 @@ extern "C" void SAL_CALL freeProxyCallback(
static_cast< Proxy * >(pProxy)->do_free();
}
-void joinThread(osl::Thread * thread) {
+void joinThread(salhelper::Thread * thread) {
assert(thread != 0);
if (thread->getIdentifier() != osl::Thread::getCurrentIdentifier()) {
thread->join();
@@ -239,9 +239,9 @@ void Bridge::start() {
threadPool_ = uno_threadpool_create();
assert(threadPool_ != 0);
writer_.set(new Writer(this));
- writer_->create();
+ writer_->launch();
reader_.set(new Reader(this));
- reader_->create();
+ reader_->launch();
}
void Bridge::terminate() {
diff --git a/binaryurp/source/reader.cxx b/binaryurp/source/reader.cxx
index e6b6f06..a871e11 100644
--- a/binaryurp/source/reader.cxx
+++ b/binaryurp/source/reader.cxx
@@ -109,15 +109,15 @@ extern "C" void SAL_CALL request(void * pThreadSpecificData) {
}
-Reader::Reader(rtl::Reference< Bridge > const & bridge): bridge_(bridge) {
+Reader::Reader(rtl::Reference< Bridge > const & bridge):
+ Thread("binaryurpReader"), bridge_(bridge)
+{
assert(bridge.is());
- acquire();
}
Reader::~Reader() {}
-void Reader::run() {
- setName("binaryurpReader");
+void Reader::execute() {
try {
bridge_->sendRequestChangeRequest();
css::uno::Reference< css::connection::XConnection > con(
@@ -153,10 +153,6 @@ void Reader::run() {
bridge_->terminate();
}
-void Reader::onTerminated() {
- release();
-}
-
void Reader::readMessage(Unmarshal & unmarshal) {
sal_uInt8 flags1 = unmarshal.read8();
bool newType;
diff --git a/binaryurp/source/reader.hxx b/binaryurp/source/reader.hxx
index 3fb2fe3..4fa923b 100644
--- a/binaryurp/source/reader.hxx
+++ b/binaryurp/source/reader.hxx
@@ -31,15 +31,11 @@
#include "sal/config.h"
-#include <cstddef>
-
-#include "boost/noncopyable.hpp"
-#include "osl/thread.hxx"
#include "rtl/byteseq.hxx"
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
-#include "salhelper/simplereferenceobject.hxx"
+#include "salhelper/thread.hxx"
#include "typelib/typedescription.hxx"
#include "readerstate.hxx"
@@ -52,25 +48,14 @@ namespace binaryurp {
namespace binaryurp {
-class Reader:
- public osl::Thread, public salhelper::SimpleReferenceObject,
- private boost::noncopyable
-{
+class Reader: public salhelper::Thread {
public:
- static void * operator new(std::size_t size)
- { return Thread::operator new(size); }
-
- static void operator delete(void * pointer)
- { Thread::operator delete(pointer); }
-
explicit Reader(rtl::Reference< Bridge > const & bridge);
private:
virtual ~Reader();
- virtual void SAL_CALL run();
-
- virtual void SAL_CALL onTerminated();
+ virtual void execute();
void readMessage(Unmarshal & unmarshal);
diff --git a/binaryurp/source/writer.cxx b/binaryurp/source/writer.cxx
index 843f667..f5ded29 100644
--- a/binaryurp/source/writer.cxx
+++ b/binaryurp/source/writer.cxx
@@ -77,10 +77,10 @@ Writer::Item::Item(
{}
Writer::Writer(rtl::Reference< Bridge > const & bridge):
- bridge_(bridge), marshal_(bridge, state_), stop_(false)
+ Thread("binaryurpWriter"), bridge_(bridge), marshal_(bridge, state_),
+ stop_(false)
{
OSL_ASSERT(bridge.is());
- acquire();
}
void Writer::sendDirectRequest(
@@ -148,8 +148,7 @@ void Writer::stop() {
Writer::~Writer() {}
-void Writer::run() {
- setName("binaryurpWriter");
+void Writer::execute() {
try {
unblocked_.wait();
for (;;) {
@@ -199,10 +198,6 @@ void Writer::run() {
bridge_->terminate();
}
-void Writer::onTerminated() {
- release();
-}
-
void Writer::sendRequest(
rtl::ByteSequence const & tid, rtl::OUString const & oid,
css::uno::TypeDescription const & type,
diff --git a/binaryurp/source/writer.hxx b/binaryurp/source/writer.hxx
index 60d097e..e7ae0a2 100644
--- a/binaryurp/source/writer.hxx
+++ b/binaryurp/source/writer.hxx
@@ -31,19 +31,15 @@
#include "sal/config.h"
-#include <cstddef>
#include <deque>
#include <vector>
-#include "boost/noncopyable.hpp"
#include "osl/conditn.hxx"
#include "osl/mutex.hxx"
-#include "osl/thread.hxx"
#include "rtl/byteseq.hxx"
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
-#include "sal/types.h"
-#include "salhelper/simplereferenceobject.hxx"
+#include "salhelper/thread.hxx"
#include "typelib/typedescription.hxx"
#include "uno/dispatcher.hxx"
@@ -55,17 +51,9 @@ namespace binaryurp { class Bridge; }
namespace binaryurp {
-class Writer:
- public osl::Thread, public salhelper::SimpleReferenceObject,
- private boost::noncopyable
+class Writer: public salhelper::Thread
{
public:
- static void * operator new(std::size_t size)
- { return Thread::operator new(size); }
-
- static void operator delete(void * pointer)
- { Thread::operator delete(pointer); }
-
explicit Writer(rtl::Reference< Bridge > const & bridge);
// Only called from Bridge::reader_ thread, and only before Bridge::writer_
@@ -104,9 +92,7 @@ public:
private:
virtual ~Writer();
- virtual void SAL_CALL run();
-
- virtual void SAL_CALL onTerminated();
+ virtual void execute();
void sendRequest(
rtl::ByteSequence const & tid, rtl::OUString const & oid,
commit 0a5dcfe4a1955879f9a0d08ab5f2e826e9d4c2b9
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:29:19 2012 +0100
Adapted AsynchReader to safer-to-use salhelper::Thread
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index d541bea..a3176fa 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -31,13 +31,13 @@
#include "osl/process.h"
#include "osl/security.hxx"
-#include "osl/thread.hxx"
#include "osl/file.hxx"
#include "osl/module.hxx"
#include "rtl/byteseq.hxx"
#include "rtl/ustrbuf.hxx"
#include "rtl/instance.hxx"
-#include <salhelper/linkhelper.hxx>
+#include "salhelper/linkhelper.hxx"
+#include "salhelper/thread.hxx"
#include "boost/scoped_array.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include <utility>
@@ -294,7 +294,7 @@ FileHandleReader::readLine(rtl::OString * pLine)
}
}
-class AsynchReader: public Thread
+class AsynchReader: public salhelper::Thread
{
size_t m_nDataSize;
boost::scoped_array<sal_Char> m_arData;
@@ -303,7 +303,9 @@ class AsynchReader: public Thread
bool m_bDone;
FileHandleGuard m_aGuard;
- void SAL_CALL run();
+ virtual ~AsynchReader() {}
+
+ void execute();
public:
AsynchReader(oslFileHandle & rHandle);
@@ -317,17 +319,17 @@ public:
};
AsynchReader::AsynchReader(oslFileHandle & rHandle):
- m_nDataSize(0), m_bError(false), m_bDone(false), m_aGuard(rHandle)
+ Thread("jvmfwkAsyncReader"), m_nDataSize(0), m_bError(false),
+ m_bDone(false), m_aGuard(rHandle)
{
}
OString AsynchReader::getData()
{
- OSL_ASSERT(isRunning() == sal_False );
return OString(m_arData.get(), m_nDataSize);
}
-void AsynchReader::run()
+void AsynchReader::execute()
{
const sal_uInt64 BUFFER_SIZE = 4096;
sal_Char aBuffer[BUFFER_SIZE];
@@ -420,7 +422,7 @@ bool getJavaProps(const OUString & exePath,
oslFileHandle fileErr= 0;
FileHandleReader stdoutReader(fileOut);
- AsynchReader stderrReader(fileErr);
+ rtl::Reference< AsynchReader > stderrReader(new AsynchReader(fileErr));
JFW_TRACE2(OUSTR("\n[Java framework] Executing: ") + exePath + OUSTR(".\n"));
oslProcessError procErr =
@@ -450,7 +452,7 @@ bool getJavaProps(const OUString & exePath,
}
//Start asynchronous reading (different thread) of error stream
- stderrReader.create();
+ stderrReader->launch();
//Use this thread to read output stream
FileHandleReader::Result rs = FileHandleReader::RESULT_OK;
@@ -489,9 +491,9 @@ bool getJavaProps(const OUString & exePath,
ret = true;
//process error stream data
- stderrReader.join();
+ stderrReader->join();
JFW_TRACE2("[Java framework] Java wrote to stderr:\" "
- << stderrReader.getData().getStr() << " \".\n");
+ << stderrReader->getData().getStr() << " \".\n");
TimeValue waitMax= {5 ,0};
procErr = osl_joinProcessWithTimeout(javaProcess, &waitMax);
commit f7afe3b7b07800d130b4d9102f2a94ccac0ebc52
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:28:53 2012 +0100
Adapted TickerThread to safer-to-use salhelper::Thread
diff --git a/ucb/source/ucp/webdav/NeonLockStore.cxx b/ucb/source/ucp/webdav/NeonLockStore.cxx
index 1ad726a..3c84ad3 100644
--- a/ucb/source/ucp/webdav/NeonLockStore.cxx
+++ b/ucb/source/ucp/webdav/NeonLockStore.cxx
@@ -32,6 +32,7 @@
#include "rtl/ustring.hxx"
#include "osl/time.h"
#include "osl/thread.hxx"
+#include "salhelper/thread.hxx"
#include "NeonSession.hxx"
#include "NeonLockStore.hxx"
@@ -39,7 +40,7 @@ using namespace webdav_ucp;
namespace webdav_ucp {
-class TickerThread : public osl::Thread
+class TickerThread : public salhelper::Thread
{
bool m_bFinish;
NeonLockStore & m_rLockStore;
@@ -47,19 +48,20 @@ class TickerThread : public osl::Thread
public:
TickerThread( NeonLockStore & rLockStore )
- : osl::Thread(), m_bFinish( false ), m_rLockStore( rLockStore ) {}
+ : Thread( "NeonTickerThread" ), m_bFinish( false ),
+ m_rLockStore( rLockStore ) {}
void finish() { m_bFinish = true; }
-protected:
+private:
- virtual void SAL_CALL run();
+ virtual void execute();
};
} // namespace webdav_ucp
// -------------------------------------------------------------------
-void TickerThread::run()
+void TickerThread::execute()
{
OSL_TRACE( "TickerThread: start." );
@@ -78,7 +80,7 @@ void TickerThread::run()
TimeValue aTV;
aTV.Seconds = 0;
aTV.Nanosec = 1000000000 / nNth;
- wait( aTV );
+ osl::Thread::wait( aTV );
}
OSL_TRACE( "TickerThread: stop." );
@@ -86,8 +88,7 @@ void TickerThread::run()
// -------------------------------------------------------------------
NeonLockStore::NeonLockStore()
- : m_pNeonLockStore( ne_lockstore_create() ),
- m_pTickerThread( 0 )
+ : m_pNeonLockStore( ne_lockstore_create() )
{
OSL_ENSURE( m_pNeonLockStore, "Unable to create neon lock store!" );
}
@@ -122,10 +123,10 @@ void NeonLockStore::startTicker()
{
osl::MutexGuard aGuard( m_aMutex );
- if ( !m_pTickerThread )
+ if ( !m_pTickerThread.is() )
{
m_pTickerThread = new TickerThread( *this );
- m_pTickerThread->create();
+ m_pTickerThread->launch();
}
}
@@ -134,12 +135,11 @@ void NeonLockStore::stopTicker()
{
osl::MutexGuard aGuard( m_aMutex );
- if ( m_pTickerThread )
+ if ( m_pTickerThread.is() )
{
m_pTickerThread->finish();
m_pTickerThread->join();
- delete m_pTickerThread;
- m_pTickerThread = 0;
+ m_pTickerThread.clear();
}
}
diff --git a/ucb/source/ucp/webdav/NeonLockStore.hxx b/ucb/source/ucp/webdav/NeonLockStore.hxx
index 3b6fbde..c8f0f0f 100644
--- a/ucb/source/ucp/webdav/NeonLockStore.hxx
+++ b/ucb/source/ucp/webdav/NeonLockStore.hxx
@@ -69,7 +69,7 @@ class NeonLockStore
{
osl::Mutex m_aMutex;
ne_lock_store * m_pNeonLockStore;
- TickerThread * m_pTickerThread;
+ rtl::Reference< TickerThread > m_pTickerThread;
LockInfoMap m_aLockInfoMap;
public:
commit 123c59342c7191ae7972b76da2ccd28788ac7cee
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:28:28 2012 +0100
Adapted GCThread to safer-to-use salhelper::Thread
diff --git a/pyuno/prj/build.lst b/pyuno/prj/build.lst
index a7c1c5b..8d0f8ba 100644
--- a/pyuno/prj/build.lst
+++ b/pyuno/prj/build.lst
@@ -1,4 +1,4 @@
-bgpu pyuno : stoc cpputools cppuhelper bridges tools PYTHON:python LIBXSLT:libxslt NULL
+bgpu pyuno : salhelper stoc cpputools cppuhelper bridges tools PYTHON:python LIBXSLT:libxslt NULL
pu pyuno usr1 - all br_mkout NULL
pu pyuno\zipcore nmake - all pu_zipcore NULL
pu pyuno\source\module nmake - all pu_module NULL
diff --git a/pyuno/source/module/makefile.mk b/pyuno/source/module/makefile.mk
index 714a120..5c9d81e 100644
--- a/pyuno/source/module/makefile.mk
+++ b/pyuno/source/module/makefile.mk
@@ -92,6 +92,7 @@ SHL1STDLIBS= \
$(CPPULIB) \
$(CPPUHELPERLIB) \
$(SALLIB) \
+ $(SALHELPERLIB) \
$(PYTHONLIB) \
$(EXTRA_FRAMEWORK_FLAG)
diff --git a/pyuno/source/module/pyuno_gc.cxx b/pyuno/source/module/pyuno_gc.cxx
index 6ee657e..cd91187 100644
--- a/pyuno/source/module/pyuno_gc.cxx
+++ b/pyuno/source/module/pyuno_gc.cxx
@@ -25,8 +25,14 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#include <pyuno_impl.hxx>
-#include <osl/thread.hxx>
+
+#include "pyuno_impl.hxx"
+
+#include "sal/config.h"
+
+#include "rtl/ref.hxx"
+#include "salhelper/thread.hxx"
+
namespace pyuno
{
@@ -47,25 +53,25 @@ static bool isAfterUnloadOrPy_Finalize()
!Py_IsInitialized();
}
-class GCThread : public ::osl::Thread
-{
- PyObject *mPyObject;
- PyInterpreterState *mPyInterpreter;
- GCThread( const GCThread & ); // not implemented
- GCThread &operator =( const GCThread & ); // not implemented
-
+class GCThread: public salhelper::Thread {
public:
GCThread( PyInterpreterState *interpreter, PyObject * object );
- virtual void SAL_CALL run();
- virtual void SAL_CALL onTerminated();
-};
+private:
+ virtual ~GCThread() {}
+
+ virtual void execute();
+
+ PyObject *mPyObject;
+ PyInterpreterState *mPyInterpreter;
+};
GCThread::GCThread( PyInterpreterState *interpreter, PyObject * object ) :
- mPyObject( object ), mPyInterpreter( interpreter )
+ Thread( "pyunoGCThread" ), mPyObject( object ),
+ mPyInterpreter( interpreter )
{}
-void GCThread::run()
+void GCThread::execute()
{
// otherwise we crash here, when main has been left already
if( isAfterUnloadOrPy_Finalize() )
@@ -95,12 +101,6 @@ void GCThread::run()
}
}
-
-void GCThread::onTerminated()
-{
- delete this;
-}
-
void decreaseRefCount( PyInterpreterState *interpreter, PyObject *object )
{
// otherwise we crash in the last after main ...
@@ -111,11 +111,11 @@ void decreaseRefCount( PyInterpreterState *interpreter, PyObject *object )
// to be a method, which tells, whether the global
// interpreter lock is held or not
// TODO: Look for a more efficient solution
- osl::Thread *t = new GCThread( interpreter, object );
- // don't call create() because Valgrind complains about invalid read in
- // the rather bizarre GCThread::onTerminated; try a lame workaround:
- t->createSuspended();
- t->resume();
+ rtl::Reference< GCThread >(new GCThread(interpreter, object))->launch();
+ //TODO: a protocol is missing how to join with the launched thread
+ // before exit(3), to ensure the thread is no longer relying on any
+ // infrastructure while that infrastructure is being shut down in
+ // atexit handlers
}
}
commit a342b3e3b0c4c2baa40442ab4580f5091c6231d1
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 23 10:25:39 2012 +0100
Moved dp_gui::Thread to salhelper::Thread, so that all code can use it
...also improved the code somewhat.
diff --git a/desktop/Library_deploymentgui.mk b/desktop/Library_deploymentgui.mk
index 2ce8622..9594848 100644
--- a/desktop/Library_deploymentgui.mk
+++ b/desktop/Library_deploymentgui.mk
@@ -79,7 +79,6 @@ $(eval $(call gb_Library_add_exception_objects,deploymentgui,\
desktop/source/deployment/gui/dp_gui_extlistbox \
desktop/source/deployment/gui/dp_gui_service \
desktop/source/deployment/gui/dp_gui_theextmgr \
- desktop/source/deployment/gui/dp_gui_thread \
desktop/source/deployment/gui/dp_gui_updatedialog \
desktop/source/deployment/gui/dp_gui_updateinstalldialog \
desktop/source/deployment/gui/license_dialog \
diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
index 62347ce..ae37a1d 100644
--- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
@@ -71,6 +71,7 @@
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
+#include "salhelper/thread.hxx"
#include "ucbhelper/content.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "cppuhelper/implbase3.hxx"
@@ -79,7 +80,6 @@
#include "toolkit/helper/vclunohelper.hxx"
#include "dp_gui.h"
-#include "dp_gui_thread.hxx"
#include "dp_gui_extensioncmdqueue.hxx"
#include "dp_gui_dependencydialog.hxx"
#include "dp_gui_dialog2.hxx"
@@ -230,7 +230,7 @@ struct ExtensionCmd
typedef ::boost::shared_ptr< ExtensionCmd > TExtensionCmd;
//------------------------------------------------------------------------------
-class ExtensionCmdQueue::Thread: public dp_gui::Thread
+class ExtensionCmdQueue::Thread: public salhelper::Thread
{
public:
Thread( DialogHelper *pDialogHelper,
@@ -249,13 +249,9 @@ public:
bool isBusy();
private:
- Thread( Thread & ); // not defined
- void operator =( Thread & ); // not defined
-
virtual ~Thread();
virtual void execute();
- virtual void SAL_CALL onTerminated();
void _insert(const TExtensionCmd& rExtCmd);
@@ -290,7 +286,6 @@ private:
osl::Condition m_wakeup;
osl::Mutex m_mutex;
Input m_eInput;
- bool m_bTerminated;
bool m_bStopped;
bool m_bWorking;
};
@@ -624,6 +619,7 @@ void ProgressCmdEnv::pop()
ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper,
TheExtensionManager *pManager,
const uno::Reference< uno::XComponentContext > & rContext ) :
+ salhelper::Thread( "dp_gui_extensioncmdqueue" ),
m_xContext( rContext ),
m_pDialogHelper( pDialogHelper ),
m_pManager( pManager ),
@@ -634,7 +630,6 @@ ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper,
m_sDefaultCmd( DialogHelper::getResourceString( RID_STR_ADD_PACKAGES ) ),
m_sAcceptLicense( DialogHelper::getResourceString( RID_STR_ACCEPT_LICENSE ) ),
m_eInput( NONE ),
- m_bTerminated( false ),
m_bStopped( false ),
m_bWorking( false )
{
@@ -1078,13 +1073,6 @@ void ExtensionCmdQueue::Thread::_acceptLicense( ::rtl::Reference< ProgressCmdEnv
{}
}
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list