[Libreoffice-commits] core.git: stoc/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 19 19:04:44 UTC 2021
stoc/source/uriproc/UriReference.cxx | 14 ++++++++++----
stoc/source/uriproc/UriReference.hxx | 21 +++++++++++----------
2 files changed, 21 insertions(+), 14 deletions(-)
New commits:
commit d001836139b28d367cc70b64a13519d173066df1
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Aug 19 17:35:04 2021 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Aug 19 21:04:10 2021 +0200
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 at redhat.com>
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;
};
}
More information about the Libreoffice-commits
mailing list