Skip to content

Commit

Permalink
[win32] LvData: hListView is used even for regular RFT_LISTDATA.
Browse files Browse the repository at this point in the history
This fixes a seemingly-empty ListView for e.g. Win32 export/import tables
and a bunch of assertions in the debug build.

Initialize hListView (and optionally pField) in the LvData constructor
using explicit constructor arguments.

RP_ShellPropSheetExt_Private::updateMulti(): Check for a non-NULL pField
instead of hListView, since hListView is always set now.

It *may* have been introduced in commit 8cf01a1.
([win32] RP_ShellPropSheetExt: Initial RFT_LISTDATA sorting functionality)
Affects: v1.8 - v2.2.3 (Windows only)

Fixes #413: Exports/Imports table in win32 shell ext page showing blank rows
Reported by @ksharperd.
  • Loading branch information
GerbilSoft committed Apr 14, 2024
1 parent fcfeea7 commit 59c3d23
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
Attributes tab. This was already added to the GTK and KDE UI frontends
when Extended Attributes was added, but I forgot to do so for Windows.
* KDE: MessageWidget sounds now work on KF6.
* Windows: Fix seemingly-empty ListViews for e.g. Win32 export/import tables.
Affects RFT_LISTDATA, but not RFT_LISTDATA_MULTI.
* Fixes #413: Exports/Imports table in win32 shell ext page showing blank rows
* Reported by @ksharperd.

## v2.3 (released 2024/03/03)

Expand Down
10 changes: 5 additions & 5 deletions src/win32/LvData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// NOTE: Not making vImageList a pointer, since that adds
// significantly more complexity.
struct LvData {
std::vector<std::vector<std::tstring> > vvStr; // String data.
std::vector<int> vImageList; // ImageList indexes.
HWND hListView; // Associated ListView control
std::vector<std::vector<std::tstring> > vvStr; // String data
std::vector<int> vImageList; // ImageList indexes

// Sorting: key == display index, value == LvData_t index
std::vector<unsigned int> vSortMap;
Expand All @@ -35,7 +36,6 @@ struct LvData {
std::vector<int> col_widths;

// For RFT_LISTDATA_MULTI only!
HWND hListView;
const LibRpBase::RomFields::Field *pField;

// Column 0 size adjustment.
Expand All @@ -46,8 +46,8 @@ struct LvData {
uint32_t sortingMethods; // Sorting methods.
bool hasCheckboxes; // True if checkboxes are valid.

LvData()
: hListView(nullptr), pField(nullptr)
explicit LvData(HWND hListView, LibRpBase::RomFields::Field *pField = nullptr)
: hListView(hListView), pField(pField)
, col0sizeadj(0), checkboxes(0)
, sortingMethods(0), hasCheckboxes(false)
{}
Expand Down
5 changes: 2 additions & 3 deletions src/win32/RP_ShellPropSheetExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ int RP_ShellPropSheetExt_Private::initListData(_In_ HWND hWndTab,
// LVS_OWNERDATA.
vector<vector<tstring> > lvStringData;
lvStringData.reserve(list_data->size());
LvData lvData;
LvData lvData(hListView);
lvData.vvStr.reserve(list_data->size());
lvData.hasCheckboxes = hasCheckboxes;
lvData.col_widths.resize(colCount);
Expand Down Expand Up @@ -1139,7 +1139,6 @@ int RP_ShellPropSheetExt_Private::initListData(_In_ HWND hWndTab,
}

if (isMulti) {
lvData.hListView = hListView;
lvData.pField = &field;
}

Expand Down Expand Up @@ -1383,7 +1382,7 @@ void RP_ShellPropSheetExt_Private::updateMulti(uint32_t user_lc)
// RFT_LISTDATA_MULTI
for (auto &&mlvd : map_lvData) {
LvData &lvData = mlvd.second;
if (!lvData.hListView) {
if (!lvData.pField) {
// Not an RFT_LISTDATA_MULTI.
continue;
}
Expand Down

0 comments on commit 59c3d23

Please sign in to comment.