If I call nwg::ListView::insert_column for a ListViewStyle::Detailed list view twice, Rust app freezes at the 2nd call. (Environment: Windows 10 PC, GNU compiler under MSYS2, Rust installed from MSYS2)
Eg:
If I experiment and change listview.rs insert_column and use
let col_count = 0
instead of
let col_count = self.column_len() as i32;
and my app specifies index 0 and 1, than no issue.
It seems listview.rs column_len() can enter an infinite loop, as Windows LVM_GETCOLUMNWIDTH call might return anything for LVS_REPORT style lists if a column does not exist.
pub fn column_len(&self) -> usize {
use winapi::um::commctrl::LVM_GETCOLUMNWIDTH;
let handle = check_hwnd(&self.handle, NOT_BOUND, BAD_HANDLE);
let mut count = 0;
while wh::send_message(handle, LVM_GETCOLUMNWIDTH, count, 0) != 0 {
count += 1;
}
count
}
MS documentation for LVM_GETCOLUMNWIDTH (
https://docs.microsoft.com/en-us/windows/win32/controls/lvm-getcolumnwidth documentation ) states
"Returns the column width if successful, or zero otherwise. If this message is sent to a list-view control with the LVS_REPORT style and the specified column does not exist, the return value is undefined."
Could not you rely somehow on LVM_GETCOLUMN instead of LVM_GETCOLUMNWIDTH to avoid infinite loops?
If I call nwg::ListView::insert_column for a ListViewStyle::Detailed list view twice, Rust app freezes at the 2nd call. (Environment: Windows 10 PC, GNU compiler under MSYS2, Rust installed from MSYS2) Eg:
If I experiment and change listview.rs insert_column and use
let col_count = 0
instead oflet col_count = self.column_len() as i32;
and my app specifies index 0 and 1, than no issue.It seems listview.rs column_len() can enter an infinite loop, as Windows LVM_GETCOLUMNWIDTH call might return anything for LVS_REPORT style lists if a column does not exist.
MS documentation for LVM_GETCOLUMNWIDTH ( https://docs.microsoft.com/en-us/windows/win32/controls/lvm-getcolumnwidth documentation ) states "Returns the column width if successful, or zero otherwise. If this message is sent to a list-view control with the LVS_REPORT style and the specified column does not exist, the return value is undefined."
Could not you rely somehow on LVM_GETCOLUMN instead of LVM_GETCOLUMNWIDTH to avoid infinite loops?