Skip to content

Commit

Permalink
Check that files exists before reading their mod times
Browse files Browse the repository at this point in the history
This will prevent log warnings when a file has been deleted and the window repaints.
  • Loading branch information
Blake-Madden committed Feb 11, 2024
1 parent c1981ee commit d2beb1b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions startpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ void wxStartPage::OnPaintWindow(wxPaintEvent& WXUNUSED(event))
{
const wxFileName fn(m_fileButtons[i].m_fullFilePath);
wxDateTime accessTime, modTime, createTime;
if (fn.GetTimes(&accessTime, &modTime, &createTime))
if (fn.FileExists() && fn.GetTimes(&accessTime, &modTime, &createTime))
{
const wxString modTimeStr =
formatFileDateTime(modTime);
Expand Down Expand Up @@ -697,7 +697,7 @@ void wxStartPage::OnPaintWindow(wxPaintEvent& WXUNUSED(event))
// truncate the path is necessary
(m_fileButtons[i].m_label.length() <= 75) ?
m_fileButtons[i].m_label :
(m_fileButtons[i].m_label.substr(0,75) + L"..."),
(m_fileButtons[i].m_label.substr(0, 75) + L"..."),
wxPoint(fileLabelRect.GetLeft() +
GetLabelPaddingWidth() +
fileIcon.GetWidth(),
Expand All @@ -711,7 +711,7 @@ void wxStartPage::OnPaintWindow(wxPaintEvent& WXUNUSED(event))
fileLabelRect.GetWidth())
{
wxDateTime accessTime, modTime, createTime;
if (fn.GetTimes(&accessTime, &modTime, &createTime))
if (fn.FileExists() && fn.GetTimes(&accessTime, &modTime, &createTime))
{
const wxString modTimeStr =
formatFileDateTime(modTime);
Expand Down

0 comments on commit d2beb1b

Please sign in to comment.