mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-14 00:47:30 +00:00
Avoid forming owning_lock of incomplete type in history
Older libstdc++ will error on this. Partially addresses #7023
This commit is contained in:
parent
285861d346
commit
1fd0cd5510
2 changed files with 12 additions and 5 deletions
|
@ -1231,20 +1231,26 @@ static bool string_could_be_path(const wcstring &potential_path) {
|
||||||
return !(potential_path.empty() || potential_path.at(0) == L'-');
|
return !(potential_path.empty() || potential_path.at(0) == L'-');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// impl_wrapper_t is used to avoid forming owning_lock<incomplete_type> in
|
||||||
|
/// the .h file; see #7023.
|
||||||
|
struct history_t::impl_wrapper_t {
|
||||||
|
owning_lock<history_impl_t> impl;
|
||||||
|
explicit impl_wrapper_t(wcstring &&name) : impl(history_impl_t(std::move(name))) {}
|
||||||
|
};
|
||||||
|
|
||||||
/// Very simple, just mark that we have no more pending items.
|
/// Very simple, just mark that we have no more pending items.
|
||||||
void history_impl_t::resolve_pending() { this->has_pending_item = false; }
|
void history_impl_t::resolve_pending() { this->has_pending_item = false; }
|
||||||
|
|
||||||
bool history_t::chaos_mode = false;
|
bool history_t::chaos_mode = false;
|
||||||
bool history_t::never_mmap = false;
|
bool history_t::never_mmap = false;
|
||||||
|
|
||||||
history_t::history_t(wcstring name)
|
history_t::history_t(wcstring name) : wrap_(make_unique<impl_wrapper_t>(std::move(name))) {}
|
||||||
: impl_(make_unique<owning_lock<history_impl_t>>(history_impl_t(std::move(name)))) {}
|
|
||||||
|
|
||||||
history_t::~history_t() = default;
|
history_t::~history_t() = default;
|
||||||
|
|
||||||
acquired_lock<history_impl_t> history_t::impl() { return impl_->acquire(); }
|
acquired_lock<history_impl_t> history_t::impl() { return wrap_->impl.acquire(); }
|
||||||
|
|
||||||
acquired_lock<const history_impl_t> history_t::impl() const { return impl_->acquire(); }
|
acquired_lock<const history_impl_t> history_t::impl() const { return wrap_->impl.acquire(); }
|
||||||
|
|
||||||
bool history_t::is_default() const { return impl()->is_default(); }
|
bool history_t::is_default() const { return impl()->is_default(); }
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,8 @@ struct history_impl_t;
|
||||||
|
|
||||||
class history_t {
|
class history_t {
|
||||||
friend class history_tests_t;
|
friend class history_tests_t;
|
||||||
const std::unique_ptr<owning_lock<history_impl_t>> impl_;
|
struct impl_wrapper_t;
|
||||||
|
const std::unique_ptr<impl_wrapper_t> wrap_;
|
||||||
|
|
||||||
// No copying or moving.
|
// No copying or moving.
|
||||||
history_t() = delete;
|
history_t() = delete;
|
||||||
|
|
Loading…
Reference in a new issue