summaryrefslogtreecommitdiff
path: root/configmgr/source/components.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr/source/components.cxx')
-rwxr-xr-x[-rw-r--r--]configmgr/source/components.cxx28
1 files changed, 24 insertions, 4 deletions
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index 2d148959edfc..108e08fa7a12 100644..100755
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -182,6 +183,7 @@ private:
rtl::OUString url_;
Data const & data_;
osl::Condition delay_;
+ boost::shared_ptr<osl::Mutex> lock_;
};
Components::WriteThread::WriteThread(
@@ -189,6 +191,7 @@ Components::WriteThread::WriteThread(
rtl::OUString const & url, Data const & data):
reference_(reference), components_(components), url_(url), data_(data)
{
+ lock_ = lock();
OSL_ASSERT(reference != 0);
acquire();
}
@@ -196,7 +199,7 @@ Components::WriteThread::WriteThread(
void Components::WriteThread::run() {
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
+ osl::MutexGuard g(*lock_); // must not throw
try {
try {
writeModFile(components_, url_, data_);
@@ -219,9 +222,9 @@ Components & Components::getSingleton(
{
OSL_ASSERT(context.is());
if (!singletonCreated) {
- singletonCreated = true;
static Components theSingleton(context);
singleton = &theSingleton;
+ singletonCreated = true;
}
if (singleton == 0) {
throw css::uno::RuntimeException(
@@ -299,7 +302,17 @@ void Components::addModification(Path const & path) {
data_.modifications.add(path);
}
+bool Components::hasModifications() const
+{
+ return data_.modifications.getRoot().children.begin() !=
+ data_.modifications.getRoot().children.end();
+}
+
void Components::writeModifications() {
+
+ if (!hasModifications())
+ return;
+
if (!writeThread_.is()) {
writeThread_ = new WriteThread(
&writeThread_, *this, getModificationFileUrl(), data_);
@@ -310,7 +323,7 @@ void Components::writeModifications() {
void Components::flushModifications() {
rtl::Reference< WriteThread > thread;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
thread = writeThread_;
}
if (thread.is()) {
@@ -501,6 +514,8 @@ Components::Components(
css::uno::Reference< css::uno::XComponentContext > const & context):
context_(context)
{
+ lock_ = lock();
+
OSL_ASSERT(context.is());
RTL_LOGFILE_TRACE_AUTHOR("configmgr", "sb", "begin parsing");
parseXcsXcuLayer(
@@ -576,7 +591,10 @@ Components::Components(
RTL_LOGFILE_TRACE_AUTHOR("configmgr", "sb", "end parsing");
}
-Components::~Components() {}
+Components::~Components()
+{
+ flushModifications();
+}
void Components::parseFileLeniently(
FileParser * parseFile, rtl::OUString const & url, int layer, Data & data,
@@ -861,3 +879,5 @@ void Components::parseModificationLayer() {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */