merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0109-gnome-vfs-late-init.diff
bloba15d33005c5ada4bbf840985de497de20f300cd4
1 diff --git desktop/source/app/appinit.cxx desktop/source/app/appinit.cxx
2 index 6a982ad..e4c1168 100644
3 --- desktop/source/app/appinit.cxx
4 +++ desktop/source/app/appinit.cxx
5 @@ -153,7 +153,7 @@
7 Reference<XContentProviderManager> xCPM =
8 cb->getContentProviderManagerInterface();
9 -#if 0
11 try
14 @@ -174,30 +174,7 @@
15 } catch (...)
18 -#else
20 - // Workaround for P1 #124597#. Instanciate GNOME-VFS-UCP in the thread that initialized
21 - // GNOME in order to avoid a deadlock that may occure in case UCP gets initialized from
22 - // a different thread. The latter may happen when calling the Office remotely via UNO.
23 - // THIS IS NOT A FIX, JUST A WORKAROUND!
25 - try
26 - {
27 - Reference<XContentProvider> xCP(
28 - xServiceFactory->createInstance(
29 - rtl::OUString::createFromAscii(
30 - "com.sun.star.ucb.GnomeVFSContentProvider")),
31 - UNO_QUERY);
32 - if(xCP.is())
33 - xCPM->registerContentProvider(
34 - xCP,
35 - rtl::OUString::createFromAscii(".*"),
36 - false);
37 - } catch (...)
38 - {
39 - }
41 -#endif
43 } catch (RuntimeException e) {
45 --- ucb/prj/build.lst-old 2009-03-05 14:42:20.000000000 +0100
46 +++ ucb/prj/build.lst 2009-03-05 14:42:26.000000000 +0100
47 @@ -1,4 +1,4 @@
48 -uc ucb : cppuhelper CURL:curl OPENSSL:openssl NEON:neon LIBXML2:libxml2 offapi sal salhelper ucbhelper udkapi comphelper NULL
49 +uc ucb : cppuhelper CURL:curl OPENSSL:openssl NEON:neon LIBXML2:libxml2 offapi sal salhelper ucbhelper udkapi comphelper vcl NULL
50 uc ucb usr1 - all uc_mkout NULL
51 uc ucb\inc nmake - all uc_inc NULL
52 uc ucb\source\regexp nmake - all uc_regexp uc_inc NULL
53 diff --git ucb/source/ucp/gvfs/makefile.mk ucb/source/ucp/gvfs/makefile.mk
54 index 8351f6c..3bca046 100644
55 --- ucb/source/ucp/gvfs/makefile.mk
56 +++ ucb/source/ucp/gvfs/makefile.mk
57 @@ -84,6 +84,7 @@ SHL1STDLIBS=\
58 $(CPPULIB) \
59 $(SALLIB) \
60 $(SALHELPERLIB) \
61 + $(VCLLIB) \
62 $(UCBHELPERLIB)
64 SHL1STDLIBS+=$(PKGCONFIG_LIBS)
65 diff --git ucb/source/ucp/gvfs/provider.cxx ucb/source/ucp/gvfs/provider.cxx
66 index df36cfa..dad5dcb 100644
67 --- ucb/source/ucp/gvfs/provider.cxx
68 +++ ucb/source/ucp/gvfs/provider.cxx
69 @@ -32,6 +32,9 @@
70 #include "precompiled_ucb.hxx"
72 #include <ucbhelper/contentidentifier.hxx>
73 +#include <osl/mutex.hxx>
74 +#include <vcl/svapp.hxx>
76 #include <libgnomevfs/gnome-vfs-init.h>
77 #include "provider.hxx"
78 #include "content.hxx"
79 @@ -198,6 +201,55 @@ component_writeInfo( void */*pServiceManager*/,
80 ::gvfs::ContentProvider::getImplementationName_Static(),
81 ::gvfs::ContentProvider::getSupportedServiceNames_Static() );
84 +/* This class is here to be able to initialize gnome-vfs in the main thread */
85 +class GnomeVFSInitializator
87 +private:
88 + osl::Mutex m_aLock;
89 + bool m_bInitialized;
91 +public:
92 + GnomeVFSInitializator() : m_bInitialized( false ) {}
94 + void init()
95 + {
96 + Application::PostUserEvent( LINK( this, GnomeVFSInitializator, ImplInitializeGnomeVFS ) );
98 + // cannot use a condition variable here, leads to a deadlock
99 + while (1)
102 + osl::MutexGuard aGuard( m_aLock );
103 + if ( m_bInitialized )
104 + break;
106 + Application::Yield();
110 +private:
111 + DECL_LINK( ImplInitializeGnomeVFS, void* );
114 +IMPL_LINK( GnomeVFSInitializator, ImplInitializeGnomeVFS, void*, EMPTYARG )
116 + osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() );
118 + // this must be performed in the same thread where we initialized
119 + // Gtk+ (if we did)
120 + if ( !gnome_vfs_initialized () )
121 + gnome_vfs_init ();
122 + if ( !auth_queue )
123 + auth_queue = g_private_new( auth_queue_destroy );
125 + m_aLock.acquire();
126 + m_bInitialized = true;
127 + m_aLock.release();
129 + return 0;
132 extern "C" void * SAL_CALL
133 component_getFactory( const sal_Char *pImplName,
134 void *pServiceManager,
135 @@ -205,13 +257,8 @@ component_getFactory( const sal_Char *pImplName,
137 void * pRet = 0;
140 - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
141 - if (!gnome_vfs_initialized ())
142 - gnome_vfs_init ();
143 - if (!auth_queue)
144 - auth_queue = g_private_new( auth_queue_destroy );
146 + GnomeVFSInitializator aInitializator;
147 + aInitializator.init();
149 uno::Reference< lang::XMultiServiceFactory > xSMgr
150 (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );