Fix locking of public UriReference members again
...after074790ad6f"remove some locking from UriReference" (and its follow-up0f44815ce7"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>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user