gnucash master: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Sat Mar 18 16:55:26 EDT 2023
Updated via https://github.com/Gnucash/gnucash/commit/00c560d8 (commit)
via https://github.com/Gnucash/gnucash/commit/352ab8a0 (commit)
via https://github.com/Gnucash/gnucash/commit/24f52d9b (commit)
via https://github.com/Gnucash/gnucash/commit/b5f3f990 (commit)
from https://github.com/Gnucash/gnucash/commit/f6e5d209 (commit)
commit 00c560d8f5fddb2516baf75d9371db743bbe5dcb
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Mar 18 13:53:49 2023 -0700
Move operator==(const GncGUID&, const GncGUID&) to guid.[ch]pp.
diff --git a/libgnucash/engine/gnc-option-impl.cpp b/libgnucash/engine/gnc-option-impl.cpp
index 6c97e9aba9..905088884b 100644
--- a/libgnucash/engine/gnc-option-impl.cpp
+++ b/libgnucash/engine/gnc-option-impl.cpp
@@ -223,12 +223,6 @@ GncOptionQofInstanceValue::reset_default_value()
m_value = m_default_value;
}
-static bool
-operator==(const GncGUID& l, const GncGUID& r)
-{
- return guid_equal(&l, &r);
-}
-
bool
GncOptionQofInstanceValue::is_changed() const noexcept
{
diff --git a/libgnucash/engine/guid.cpp b/libgnucash/engine/guid.cpp
index 933f7ad5fe..4ec3421ded 100644
--- a/libgnucash/engine/guid.cpp
+++ b/libgnucash/engine/guid.cpp
@@ -23,6 +23,7 @@
\********************************************************************/
#include "guid.hpp"
+#include "guid.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -431,3 +432,9 @@ GUID::operator GncGUID () const noexcept
}
} // namespace gnc
+
+bool
+operator==(const GncGUID& lhs, const GncGUID& rhs)
+{
+ return gnc::GUID{lhs} == gnc::GUID{rhs};
+}
diff --git a/libgnucash/engine/guid.hpp b/libgnucash/engine/guid.hpp
index ed1f460c79..8b72e34348 100644
--- a/libgnucash/engine/guid.hpp
+++ b/libgnucash/engine/guid.hpp
@@ -62,5 +62,7 @@ bool operator != (GUID const &, GUID const &) noexcept;
bool operator == (GUID const &, GncGUID const &) noexcept;
-}
+} // namespace gnc
+
+bool operator== (const GncGUID&, const GncGUID&);
#endif
commit 352ab8a0e56c343640394208cf6d8dba282edf3c
Merge: f6e5d209cd 24f52d9b17
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Mar 18 12:19:50 2023 -0700
Merge Richard Cohen's 'minor-options-fixes' into master.
commit 24f52d9b171f5474a4d1e8c2f10a198dc462ae65
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Tue Mar 7 11:44:20 2023 +0000
Remove incorrect operator!= for GncItem
It's better to use the default std::pair implementation
- spotted by clang-tidy bugprone-suspicious-string-compare
- will always return false, because type is the same
Also,
- remove redundant "using GncItem ..."
diff --git a/libgnucash/engine/gnc-option-impl.cpp b/libgnucash/engine/gnc-option-impl.cpp
index 636960a548..6c97e9aba9 100644
--- a/libgnucash/engine/gnc-option-impl.cpp
+++ b/libgnucash/engine/gnc-option-impl.cpp
@@ -143,8 +143,6 @@ GncOptionGncOwnerValue::serialize() const noexcept
return retval;
}
-using GncItem = std::pair<QofIdTypeConst, GncGUID>;
-
static GncItem
make_gnc_item(const QofInstance* inst)
{
@@ -176,14 +174,6 @@ qof_instance_from_gnc_item(const GncItem& item)
return static_cast<QofInstance*>(qof_collection_lookup_entity(coll, &guid));
}
-static bool
-operator!=(const GncItem& left, const GncItem& right)
-{
- auto [ltype, lguid]{left};
- auto [rtype, rguid]{right};
- return strcmp(rtype, ltype) && !guid_equal(&rguid, &lguid);
-}
-
GncOptionQofInstanceValue::GncOptionQofInstanceValue(
const char* section, const char* name,
const char* key, const char* doc_string,
@@ -233,6 +223,12 @@ GncOptionQofInstanceValue::reset_default_value()
m_value = m_default_value;
}
+static bool
+operator==(const GncGUID& l, const GncGUID& r)
+{
+ return guid_equal(&l, &r);
+}
+
bool
GncOptionQofInstanceValue::is_changed() const noexcept
{
@@ -447,12 +443,6 @@ GncOptionAccountListValue::get_default_value() const
return retval;
}
-static bool
-operator==(const GncGUID& l, const GncGUID& r)
-{
- return guid_equal(&l, &r);
-}
-
bool
GncOptionAccountListValue::is_changed() const noexcept
{
commit b5f3f99035a763e41217cfd7b792e4669ce17ba7
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Tue Mar 7 11:27:21 2023 +0000
Fix incorrect use of remove_if()
- spotted by clang-tidy bugprone
- probably no visible effects because of uniqueness, and other checks
libgnucash/engine/gnc-optiondb.cpp:149:5: warning: this call will remove at most one item even when multiple items should be removed [bugprone-inaccurate-erase]
m_options.erase(std::remove_if(m_options.begin(), m_options.end(),
^
libgnucash/engine/gnc-optiondb.cpp:358:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
std::remove_if(m_callbacks.begin(), m_callbacks.end(),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libgnucash/engine/gnc-optiondb.cpp:358:5: note: cast the expression to void to silence this warning
diff --git a/libgnucash/engine/gnc-optiondb.cpp b/libgnucash/engine/gnc-optiondb.cpp
index 293bf9a24f..7ef2b10fbf 100644
--- a/libgnucash/engine/gnc-optiondb.cpp
+++ b/libgnucash/engine/gnc-optiondb.cpp
@@ -150,7 +150,7 @@ GncOptionSection::remove_option(const char* name)
[name](const auto& option) -> bool
{
return option.get_name() == name;
- }));
+ }), m_options.end());
}
const GncOption*
@@ -355,8 +355,9 @@ GncOptionDB::register_callback(GncOptionDBChangeCallback cb, void* data)
void
GncOptionDB::unregister_callback(size_t id)
{
- std::remove_if(m_callbacks.begin(), m_callbacks.end(),
- [id](auto& cb)->bool { return cb.m_id == id; });
+ m_callbacks.erase(std::remove_if(m_callbacks.begin(), m_callbacks.end(),
+ [id](auto& cb)->bool { return cb.m_id == id; }),
+ m_callbacks.end());
}
void
Summary of changes:
libgnucash/engine/gnc-option-impl.cpp | 16 ----------------
libgnucash/engine/gnc-optiondb.cpp | 7 ++++---
libgnucash/engine/guid.cpp | 7 +++++++
libgnucash/engine/guid.hpp | 4 +++-
4 files changed, 14 insertions(+), 20 deletions(-)
More information about the gnucash-changes
mailing list