summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-08-19 17:35:04 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-08-19 21:04:10 +0200
commitd001836139b28d367cc70b64a13519d173066df1 (patch)
tree4edb8960d9078f1d01a76727d50819f7f78c4e0e /stoc
parent396c0575b2935aeb039e8da260eba739d1a0ed3c (diff)
Fix locking of public UriReference members again
...after 074790ad6f4e02e7aed3f9c954f0b4005b40fa21 "remove some locking from UriReference" (and its follow-up 0f44815ce7b2925189cd603853ce55d8363549dd "loplugin:constmethods"): The m_path member is modified by UrlReference::setName in stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx. Also make the non-mutated members (for which locking is thus indeed not needed) private for now. (The original intention was that there can be further parsers for other URI schemes, which might need to modify further UriReference members. If such further parsers are ever implemented, the relevant members can be made public again, and the locking be restored where necessary.) Change-Id: I80b437fe14f43294a52e465a7e1f31ddf2ab0482 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120749 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/uriproc/UriReference.cxx14
-rw-r--r--stoc/source/uriproc/UriReference.hxx21
2 files changed, 21 insertions, 14 deletions
diff --git a/stoc/source/uriproc/UriReference.cxx b/stoc/source/uriproc/UriReference.cxx
index a47198ac2241..75298583b0c4 100644
--- a/stoc/source/uriproc/UriReference.cxx
+++ b/stoc/source/uriproc/UriReference.cxx
@@ -34,9 +34,9 @@ UriReference::UriReference(
OUString const & scheme, bool bHasAuthority,
OUString const & authority, OUString const & path,
bool bHasQuery, OUString const & query):
+ m_path(path),
m_scheme(scheme),
m_authority(authority),
- m_path(path),
m_query(query),
m_hasAuthority(bHasAuthority),
m_hasQuery(bHasQuery),
@@ -69,14 +69,16 @@ bool UriReference::isAbsolute() const {
}
-OUString UriReference::getSchemeSpecificPart() const
+OUString UriReference::getSchemeSpecificPart()
{
+ std::lock_guard g(m_mutex);
OUStringBuffer buf;
appendSchemeSpecificPart(buf);
return buf.makeStringAndClear();
}
-bool UriReference::isHierarchical() const {
+bool UriReference::isHierarchical() {
+ std::lock_guard g(m_mutex);
return m_scheme.isEmpty() || m_hasAuthority || m_path.startsWith("/");
}
@@ -88,17 +90,20 @@ const OUString& UriReference::getAuthority() const {
return m_authority;
}
-const OUString& UriReference::getPath() const {
+OUString UriReference::getPath() {
+ std::lock_guard g(m_mutex);
return m_path;
}
bool UriReference::hasRelativePath() {
+ std::lock_guard g(m_mutex);
return !m_hasAuthority
&& (m_path.isEmpty() || m_path[0] != '/');
}
sal_Int32 UriReference::getPathSegmentCount()
{
+ std::lock_guard g(m_mutex);
if (m_path.isEmpty()) {
return 0;
} else {
@@ -116,6 +121,7 @@ sal_Int32 UriReference::getPathSegmentCount()
OUString UriReference::getPathSegment(sal_Int32 index)
{
+ std::lock_guard g(m_mutex);
if (!m_path.isEmpty() && index >= 0) {
for (sal_Int32 i = m_path[0] == '/' ? 1 : 0;; ++i) {
if (index-- == 0) {
diff --git a/stoc/source/uriproc/UriReference.hxx b/stoc/source/uriproc/UriReference.hxx
index 715819789e66..e1645372038a 100644
--- a/stoc/source/uriproc/UriReference.hxx
+++ b/stoc/source/uriproc/UriReference.hxx
@@ -46,10 +46,10 @@ public:
const OUString& getScheme() const { return m_scheme;}
/// @throws css::uno::RuntimeException
- OUString getSchemeSpecificPart() const;
+ OUString getSchemeSpecificPart();
/// @throws css::uno::RuntimeException
- bool isHierarchical() const;
+ bool isHierarchical();
/// @throws css::uno::RuntimeException
bool hasAuthority() const;
@@ -58,7 +58,7 @@ public:
const OUString& getAuthority() const;
/// @throws css::uno::RuntimeException
- const OUString& getPath() const;
+ OUString getPath();
/// @throws css::uno::RuntimeException
bool hasRelativePath();
@@ -88,20 +88,21 @@ public:
void clearFragment();
std::mutex m_mutex;
- OUString m_scheme;
- OUString m_authority;
OUString m_path;
- OUString m_query;
- OUString m_fragment;
- bool m_hasAuthority;
- bool m_hasQuery;
- bool m_hasFragment;
private:
UriReference(UriReference const &) = delete;
void operator =(UriReference const &) = delete;
void appendSchemeSpecificPart(OUStringBuffer & buffer) const;
+
+ OUString m_scheme;
+ OUString m_authority;
+ OUString m_query;
+ OUString m_fragment;
+ bool m_hasAuthority;
+ bool m_hasQuery;
+ bool m_hasFragment;
};
}