mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-16 18:25:11 -06:00
Fix some return of ptr-to-temporary errors
Flagged by new clang Apple version 12.
This commit is contained in:
parent
44fc52f5c6
commit
5e6f9b3460
@ -273,7 +273,7 @@ public:
|
||||
QofBePercentageFunc get_percentage() { return m_percentage; }
|
||||
/** Retrieve the backend's storage URI.
|
||||
*/
|
||||
std::string get_uri() { return m_fullpath; }
|
||||
const std::string& get_uri() { return m_fullpath; }
|
||||
/**
|
||||
* Class methods for dynamically loading the several backends and for freeing
|
||||
* them at shutdown.
|
||||
|
@ -69,6 +69,7 @@ static QofLogModule log_module = QOF_MOD_SESSION;
|
||||
|
||||
using ProviderVec = std::vector<QofBackendProvider_ptr>;
|
||||
static ProviderVec s_providers;
|
||||
static const std::string empty_string{};
|
||||
/*
|
||||
* These getters are used in tests to reach static vars from outside
|
||||
* They should be removed when no longer needed
|
||||
@ -383,7 +384,7 @@ QofSessionImpl::get_error () noexcept
|
||||
return m_last_err;
|
||||
}
|
||||
|
||||
std::string
|
||||
const std::string&
|
||||
QofSessionImpl::get_error_message () const noexcept
|
||||
{
|
||||
return m_error_message;
|
||||
@ -414,11 +415,11 @@ QofSession::get_backend () const noexcept
|
||||
return m_backend;
|
||||
}
|
||||
|
||||
std::string
|
||||
const std::string&
|
||||
QofSessionImpl::get_file_path () const noexcept
|
||||
{
|
||||
auto backend = qof_book_get_backend (m_book);
|
||||
if (!backend) return nullptr;
|
||||
if (!backend) return empty_string;
|
||||
return backend->get_uri();
|
||||
}
|
||||
|
||||
@ -583,8 +584,9 @@ qof_session_get_book (const QofSession *session)
|
||||
const char *
|
||||
qof_session_get_file_path (const QofSession *session)
|
||||
{
|
||||
if (!session) return NULL;
|
||||
return session->get_file_path ().c_str ();
|
||||
if (!session) return nullptr;
|
||||
auto& path{session->get_file_path()};
|
||||
return path.empty() ? nullptr : path.c_str ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -68,10 +68,10 @@ struct QofSessionImpl
|
||||
* for an error in the backend.
|
||||
*/
|
||||
QofBackendError get_error () noexcept;
|
||||
std::string get_error_message () const noexcept;
|
||||
const std::string& get_error_message () const noexcept;
|
||||
QofBook * get_book () const noexcept;
|
||||
QofBackend * get_backend () const noexcept;
|
||||
std::string get_file_path () const noexcept;
|
||||
const std::string& get_file_path () const noexcept;
|
||||
bool is_saving () const noexcept;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user