Skip to content

Commit

Permalink
fix crash when deleting TGID causes the TG list to scroll;
Browse files Browse the repository at this point in the history
  • Loading branch information
gatekeep committed Jan 27, 2025
1 parent a868ff3 commit 19bbd4d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/tged/TGListWnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,23 @@ class HOST_SW_API TGListWnd final : public FDblDialog {

LogMessage(LOG_HOST, "Deleting TG %s (%u)", m_selected.name().c_str(), m_selected.source().tgId());
g_tidLookups->eraseEntry(m_selected.source().tgId(), m_selected.source().tgSlot());

// bryanb: HACK -- use HackTheGibson to access the private current listview iterator to get the scroll position
/*
* This uses the RTTI hack to access private members on FListView; and this code *could* break as a consequence.
*/
int firstScrollLinePos = 0;
if (m_listView.getCount() > 0) {
firstScrollLinePos = (m_listView.*RTTIResult<PrivateFListViewIteratorFirst>::ptr).getPosition();
}
if ((size_t)firstScrollLinePos > m_listView.getCount())
firstScrollLinePos = 0;
if (firstScrollLinePos > 0 && m_listView.getCount() > 0) {
--firstScrollLinePos;
(m_listView.*RTTIResult<PrivateFListViewScrollToY>::ptr)(firstScrollLinePos);
(m_listView.*RTTIResult<PrivateFListViewVBarPtr>::ptr)->setValue(firstScrollLinePos);
}

loadListView();
}

Expand Down

0 comments on commit 19bbd4d

Please sign in to comment.