Kaydet (Commit) 4580e570 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Tell RootAccess when Components instance is destroyed.

This is to avoid RootAccess instances, which are ref-counted, to
avoid accessing the Components instance, which is a singleton.

The problem may arise when shutting down the entire app where it's
entirely unclear whether the RootAccess instances get destroyed first
or the Components instance does.  In fact, on my Windows XP environment
this repeatedly caused crash-on-close issue which would lead to "DDE
server error" Windows system error dialog popping up afterwards.
üst b19dcd45
...@@ -504,16 +504,12 @@ css::beans::Optional< css::uno::Any > Components::getExternalValue( ...@@ -504,16 +504,12 @@ css::beans::Optional< css::uno::Any > Components::getExternalValue(
return value; return value;
} }
int tempHACK = 0;
Components::Components( Components::Components(
css::uno::Reference< css::uno::XComponentContext > const & context): css::uno::Reference< css::uno::XComponentContext > const & context):
context_(context) context_(context)
{ {
lock_ = lock(); lock_ = lock();
tempHACK = 1;
OSL_ASSERT(context.is()); OSL_ASSERT(context.is());
RTL_LOGFILE_TRACE_AUTHOR("configmgr", "sb", "begin parsing"); RTL_LOGFILE_TRACE_AUTHOR("configmgr", "sb", "begin parsing");
parseXcsXcuLayer( parseXcsXcuLayer(
...@@ -592,7 +588,9 @@ Components::Components( ...@@ -592,7 +588,9 @@ Components::Components(
Components::~Components() Components::~Components()
{ {
flushModifications(); flushModifications();
tempHACK = 0; for (WeakRootSet::iterator i(roots_.begin()); i != roots_.end(); ++i) {
(*i)->setAlive(false);
}
} }
void Components::parseFileLeniently( void Components::parseFileLeniently(
......
...@@ -77,7 +77,7 @@ RootAccess::RootAccess( ...@@ -77,7 +77,7 @@ RootAccess::RootAccess(
Components & components, rtl::OUString const & pathRepresentation, Components & components, rtl::OUString const & pathRepresentation,
rtl::OUString const & locale, bool update): rtl::OUString const & locale, bool update):
Access(components), pathRepresentation_(pathRepresentation), Access(components), pathRepresentation_(pathRepresentation),
locale_(locale), update_(update) locale_(locale), update_(update), finalized_(false), alive_(true)
{ {
lock_ = lock(); lock_ = lock();
} }
...@@ -130,10 +130,15 @@ bool RootAccess::isUpdate() const { ...@@ -130,10 +130,15 @@ bool RootAccess::isUpdate() const {
return update_; return update_;
} }
void RootAccess::setAlive(bool b) {
alive_ = b;
}
RootAccess::~RootAccess() RootAccess::~RootAccess()
{ {
osl::MutexGuard g(*lock_); osl::MutexGuard g(*lock_);
getComponents().removeRootAccess(this); if (alive_)
getComponents().removeRootAccess(this);
} }
Path RootAccess::getRelativePath() { Path RootAccess::getRelativePath() {
...@@ -291,24 +296,20 @@ void RootAccess::removeChangesListener( ...@@ -291,24 +296,20 @@ void RootAccess::removeChangesListener(
} }
} }
extern int tempHACK;
void RootAccess::commitChanges() void RootAccess::commitChanges()
throw (css::lang::WrappedTargetException, css::uno::RuntimeException) throw (css::lang::WrappedTargetException, css::uno::RuntimeException)
{ {
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
OSL_ASSERT(thisIs(IS_UPDATE)); OSL_ASSERT(thisIs(IS_UPDATE));
#endif #endif
if (!alive_)
{
return;
}
Broadcaster bc; Broadcaster bc;
{ {
osl::MutexGuard g(*lock_); osl::MutexGuard g(*lock_);
// OSL_ENSURE(tempHACK, "fucktastic!, seriously busted lifecycles\n");
if (!tempHACK)
{
return;
}
checkLocalizedPropertyAccess(); checkLocalizedPropertyAccess();
int finalizedLayer; int finalizedLayer;
Modifications globalMods; Modifications globalMods;
......
...@@ -86,6 +86,8 @@ public: ...@@ -86,6 +86,8 @@ public:
bool isUpdate() const; bool isUpdate() const;
void setAlive(bool b);
protected: protected:
virtual rtl::OUString SAL_CALL getImplementationName() virtual rtl::OUString SAL_CALL getImplementationName()
...@@ -151,14 +153,16 @@ private: ...@@ -151,14 +153,16 @@ private:
rtl::OUString pathRepresentation_; rtl::OUString pathRepresentation_;
rtl::OUString locale_; rtl::OUString locale_;
bool update_;
Path path_; Path path_;
rtl::Reference< Node > node_; rtl::Reference< Node > node_;
rtl::OUString name_; rtl::OUString name_;
bool finalized_;
ChangesListeners changesListeners_; ChangesListeners changesListeners_;
boost::shared_ptr<osl::Mutex> lock_; boost::shared_ptr<osl::Mutex> lock_;
bool update_:1;
bool finalized_:1;
bool alive_:1;
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment