diff --git a/far/changelog b/far/changelog index 9cfd040266..2e7dfbbea7 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,10 @@ +-------------------------------------------------------------------------------- +drkns 29.07.2021 19:41:27 +0100 - build 5859 + +1. Fix a potential crash at exit. + +2. Continue 5845.6 - do not populate FarDialogItem.ListItems in DN_DRAWDLGITEM. + -------------------------------------------------------------------------------- drkns 26.07.2021 17:27:54 +0100 - build 5858 diff --git a/far/common/preprocessor.hpp b/far/common/preprocessor.hpp index d461e371d0..92b1414a13 100644 --- a/far/common/preprocessor.hpp +++ b/far/common/preprocessor.hpp @@ -136,6 +136,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Type& operator=(Type&&) = delete #define MOVABLE(Type) \ + ~Type() = default; \ MOVE_CONSTRUCTIBLE(Type); \ MOVE_ASSIGNABLE(Type) diff --git a/far/dialog.cpp b/far/dialog.cpp index 4a44a74e7c..215d1f4143 100644 --- a/far/dialog.cpp +++ b/far/dialog.cpp @@ -204,7 +204,10 @@ static size_t ConvertItemEx2(const DialogItemEx *ItemEx, FarGetDialogItem *Item, auto offsetListItems = size; vmenu_ptr ListBox; size_t ListBoxSize = 0; - if (ConvertListbox && (ItemEx->Type==DI_LISTBOX || ItemEx->Type==DI_COMBOBOX)) + + const auto IsList = ItemEx->Type == DI_LISTBOX || ItemEx->Type == DI_COMBOBOX; + + if (IsList && ConvertListbox) { ListBox=ItemEx->ListPtr; if (ListBox) @@ -230,26 +233,35 @@ static size_t ConvertItemEx2(const DialogItemEx *ItemEx, FarGetDialogItem *Item, if(Item->Item && Item->Size >= size) { ConvertItemSmall(*ItemEx, *Item->Item); - if (ListBox) + + if (IsList) { - const auto list = static_cast(static_cast(reinterpret_cast(Item->Item) + offsetList)); - const auto listItems = static_cast(static_cast(reinterpret_cast(Item->Item) + offsetListItems)); - auto text = static_cast(static_cast(listItems + ListBoxSize)); - for(size_t ii = 0; ii != ListBoxSize; ++ii) + if (ConvertListbox) { - auto& item = ListBox->at(ii); - listItems[ii].Flags=item.Flags; - listItems[ii].Text=text; - text += item.Name.copy(text, item.Name.npos); - *text++ = {}; - listItems[ii].UserData = item.SimpleUserData; - listItems[ii].Reserved = 0; + const auto list = static_cast(static_cast(reinterpret_cast(Item->Item) + offsetList)); + const auto listItems = static_cast(static_cast(reinterpret_cast(Item->Item) + offsetListItems)); + auto text = static_cast(static_cast(listItems + ListBoxSize)); + for (size_t ii = 0; ii != ListBoxSize; ++ii) + { + auto& item = ListBox->at(ii); + listItems[ii].Flags = item.Flags; + listItems[ii].Text = text; + text += item.Name.copy(text, item.Name.npos); + *text++ = {}; + listItems[ii].UserData = item.SimpleUserData; + listItems[ii].Reserved = 0; + } + list->StructSize = sizeof(*list); + list->ItemsNumber = ListBoxSize; + list->Items = listItems; + Item->Item->ListItems = list; + } + else + { + Item->Item->ListItems = {}; } - list->StructSize=sizeof(*list); - list->ItemsNumber=ListBoxSize; - list->Items=listItems; - Item->Item->ListItems=list; } + auto p = static_cast(static_cast(reinterpret_cast(Item->Item) + offsetStrings)); Item->Item->Data = p; p += str.copy(p, str.npos); diff --git a/far/far.natvis b/far/far.natvis index 747d15fe7a..39794aafe0 100644 --- a/far/far.natvis +++ b/far/far.natvis @@ -43,7 +43,7 @@ - m_Data + i * m_Rows,[m_Cols]na + m_Data + i * m_Cols,[m_Cols]na ++i diff --git a/far/filelist.cpp b/far/filelist.cpp index 43813393a9..90a9ea641c 100644 --- a/far/filelist.cpp +++ b/far/filelist.cpp @@ -523,6 +523,19 @@ FileList::~FileList() } +FileList::list_data& FileList::list_data::operator=(FileList::list_data&& rhs) +{ + clear(); + + Items = std::move(rhs.Items); + rhs.Items.clear(); + + m_Plugin = std::move(rhs.m_Plugin); + rhs.m_Plugin = {}; + + return *this; +} + void FileList::list_data::clear() { for (auto& i: Items) diff --git a/far/filelist.hpp b/far/filelist.hpp index 3ae0e4e288..62a2028047 100644 --- a/far/filelist.hpp +++ b/far/filelist.hpp @@ -322,13 +322,15 @@ class FileList:public Panel { public: NONCOPYABLE(list_data); - MOVABLE(list_data); + MOVE_CONSTRUCTIBLE(list_data); using value_type = FileListItem; list_data() = default; ~list_data() { clear(); } + list_data& operator=(list_data&& rhs); + void initialise(plugin_panel* ph) { clear(); m_Plugin = ph; } void clear(); diff --git a/far/platform.concurrency.cpp b/far/platform.concurrency.cpp index fc5efb3411..0a5c7087b4 100644 --- a/far/platform.concurrency.cpp +++ b/far/platform.concurrency.cpp @@ -83,6 +83,11 @@ namespace os::concurrency thread::~thread() + { + finalise(); + } + + void thread::finalise() { if (!joinable()) return; @@ -102,6 +107,21 @@ namespace os::concurrency } } + thread& thread::operator=(thread&& rhs) + { + finalise(); + + handle::operator=(std::move(rhs)); + + m_Mode = rhs.m_Mode; + rhs.m_Mode = {}; + + m_ThreadId = rhs.m_ThreadId; + rhs.m_ThreadId = {}; + + return *this; + } + unsigned thread::get_id() const { return m_ThreadId; diff --git a/far/platform.concurrency.hpp b/far/platform.concurrency.hpp index de27491970..65ced7529f 100644 --- a/far/platform.concurrency.hpp +++ b/far/platform.concurrency.hpp @@ -81,7 +81,7 @@ namespace os::concurrency { public: NONCOPYABLE(thread); - MOVABLE(thread); + MOVE_CONSTRUCTIBLE(thread); enum class mode { @@ -102,6 +102,8 @@ namespace os::concurrency ~thread(); + thread& operator=(thread&& rhs); + [[nodiscard]] unsigned get_id() const; @@ -113,6 +115,7 @@ namespace os::concurrency private: void check_joinable() const; + void finalise(); template void starter(T&& f) diff --git a/far/vbuild.m4 b/far/vbuild.m4 index e60a4190c3..3951fb1098 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -5858 +5859