Use nullptr instead of NULL in the code and documentation

This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.

Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.

And also use null in the assert messages.

Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
This commit is contained in:
Vadim Zeitlin 2022-10-16 01:24:34 +02:00
parent 39ea524943
commit 4f4c5fcfdf
1844 changed files with 13721 additions and 13734 deletions

View file

@ -370,7 +370,7 @@ bool MyApp::OnInit()
"Progress in progress",
"Please wait, starting...",
PROGRESS_COUNT,
NULL,
nullptr,
m_startupProgressStyle
);
for ( int i = 0; i <= PROGRESS_COUNT; i++ )
@ -693,17 +693,17 @@ bool MyApp::OnInit()
// My frame constructor
MyFrame::MyFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title), m_confirmExit(false)
: wxFrame(nullptr, wxID_ANY, title), m_confirmExit(false)
{
SetIcon(wxICON(sample));
#if USE_MODAL_PRESENTATION
m_dialog = (MyModelessDialog *)NULL;
m_dialog = nullptr;
#endif // USE_MODAL_PRESENTATION
#if wxUSE_FINDREPLDLG
m_dlgFind =
m_dlgReplace = NULL;
m_dlgReplace = nullptr;
#endif
#if wxUSE_COLOURDLG
@ -766,7 +766,7 @@ MyFrame::MyFrame(const wxString& title)
#endif // wxUSE_INFOBAR
#if wxUSE_TIPWINDOW
m_tipWindow = NULL;
m_tipWindow = nullptr;
#endif // wxUSE_TIPWINDOW
#ifdef __WXMSW__
@ -2294,12 +2294,12 @@ void MyFrame::ModelessDlg(wxCommandEvent& event)
}
else // hide
{
// If m_dialog is NULL, then possibly the system
// If m_dialog is null, then possibly the system
// didn't report the checked menu item status correctly.
// It should be true just after the menu item was selected,
// if there was no modeless dialog yet.
wxASSERT( m_dialog != NULL );
wxASSERT( m_dialog != nullptr );
if (m_dialog)
m_dialog->Hide();
}
@ -2359,7 +2359,7 @@ void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event))
if ( s_index == (size_t)-1 )
{
srand(time(NULL));
srand(time(nullptr));
// this is completely bogus, we don't know how many lines are there
// in the file, but who cares, it's a demo only...
@ -2520,7 +2520,7 @@ public:
sizerSettings->Add(m_handleEvents);
#if defined(__WXMSW__) && wxUSE_TASKBARICON
m_taskbarIcon = NULL;
m_taskbarIcon = nullptr;
m_useTaskbar = new wxCheckBox(this, wxID_ANY, "Use persistent &taskbar icon");
m_useTaskbar->SetValue(false);
sizerSettings->Add(m_useTaskbar);
@ -2635,9 +2635,9 @@ private:
else
if ( m_taskbarIcon )
{
wxNotificationMessage::UseTaskBarIcon(NULL);
wxNotificationMessage::UseTaskBarIcon(nullptr);
delete m_taskbarIcon;
m_taskbarIcon = NULL;
m_taskbarIcon = nullptr;
}
#endif
}
@ -2830,7 +2830,7 @@ void MyFrame::OnShowTip(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnUpdateShowTipUI(wxUpdateUIEvent& event)
{
event.Check(m_tipWindow != NULL);
event.Check(m_tipWindow != nullptr);
}
#endif // wxUSE_TIPWINDOW
@ -3566,7 +3566,7 @@ void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
{
m_dlgReplace->Destroy();
m_dlgReplace = NULL;
m_dlgReplace = nullptr;
}
else
{
@ -3588,7 +3588,7 @@ void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
{
m_dlgFind->Destroy();
m_dlgFind = NULL;
m_dlgFind = nullptr;
}
else
{
@ -3646,13 +3646,13 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event)
{
txt = "Find";
idMenu = DIALOGS_FIND;
m_dlgFind = NULL;
m_dlgFind = nullptr;
}
else if ( dlg == m_dlgReplace )
{
txt = "Replace";
idMenu = DIALOGS_REPLACE;
m_dlgReplace = NULL;
m_dlgReplace = nullptr;
}
else
{
@ -3794,7 +3794,7 @@ void MyModalDialog::OnButton(wxCommandEvent& event)
StdButtonSizerDialog::StdButtonSizerDialog(wxWindow *parent)
: wxDialog(parent, wxID_ANY, wxString("StdButtonSizer dialog"),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),
m_buttonsSizer(NULL)
m_buttonsSizer(nullptr)
{
wxBoxSizer *const sizerTop = new wxBoxSizer(wxVERTICAL);
@ -3996,7 +3996,7 @@ SettingsDialog::SettingsDialog(wxWindow* win, SettingsData& settingsData, int di
Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
}
else
m_imageList = NULL;
m_imageList = nullptr;
Create(win, wxID_ANY, "Preferences", wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | resizeBorder);
@ -4557,7 +4557,7 @@ private:
const wxString& title,
int style) override
{
wxMessageDialog dlg(NULL, message, title,
wxMessageDialog dlg(nullptr, message, title,
wxOK | wxCANCEL | wxCANCEL_DEFAULT | style);
dlg.SetOKCancelLabels(wxID_COPY, wxID_OK);
dlg.SetExtendedMessage("Note that this is a custom log dialog.");