Skip to content

Commit

Permalink
Fix N3ME crash in CMainFrame::OnDestroy.
Browse files Browse the repository at this point in the history
Added safeguards getters for `CSliderCtrl` usages by verifying the
handle's availability before retrieving its position. This prevents
crashes related to access violation.
  • Loading branch information
stevewgr committed Nov 12, 2024
1 parent 73b1d1a commit 1f826b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/tool/N3ME/DlgBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ void CDlgBar::OnReleasedcaptureSliderLight(NMHDR * pNMHDR, LRESULT * pResult) {
return;
}
if (pFrm->GetMapMng()) {
int val = m_sld_Light.GetPos();
float lgt = (float)val / 100.0f;
pFrm->GetMapMng()->SetLight(lgt);
pFrm->GetMapMng()->SetLight(GetLight() / 100.0f);
}

*pResult = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/tool/N3ME/DlgBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class CDlgBar : public CDialog {
BOOL m_bUpdateingNow;
CDlgBar(); // standard constructor

float GetLight() { return m_sld_Light.GetSafeHwnd() ? static_cast<float>(m_sld_Light.GetPos()) : 0.0f; }
int GetTileRegion() { return m_TileRegion_Slider.GetSafeHwnd() ? m_TileRegion_Slider.GetPos() : 0; }
float GetFP() { return m_FP_Slider.GetSafeHwnd() ? static_cast<float>(m_FP_Slider.GetPos()) : 0.0f; }

// Dialog Data
//{{AFX_DATA(CDlgBar)
enum {
Expand Down
4 changes: 2 additions & 2 deletions src/tool/N3ME/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class CMainFrame : public CFrameWnd {

// Implementation
public:
float GetFP() { return (float)m_wndDlgBar.m_FP_Slider.GetPos(); }
int GetTileRegion() { return m_wndDlgBar.m_TileRegion_Slider.GetPos(); }
float GetFP() { return m_wndDlgBar.GetFP(); }
int GetTileRegion() { return m_wndDlgBar.GetTileRegion(); }
void UpdateTransformInfo();
virtual ~CMainFrame();
#ifdef _DEBUG
Expand Down

0 comments on commit 1f826b2

Please sign in to comment.