diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index 065271f877..d3ce8b644c 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -87,8 +87,8 @@ jobs: run: | git fetch --depth=1 origin master if git diff origin/master \ - ':!.github/workflows/code_checks.yml' \ - | grep -E '^\+.*(wxOVERRIDE|wxNOEXCEPT|[^_@]NULL)'; then + ':**.h' ':**.cpp' \ + | grep -E '^\+.*(wxOVERRIDE|wxNOEXCEPT|[^"_@]NULL[^"_])'; then echo "::error ::Please use C++11 equivalents of the deprecated macros in the new code." exit 1 fi diff --git a/include/wx/weakref.h b/include/wx/weakref.h index d8e16358c4..754b804400 100644 --- a/include/wx/weakref.h +++ b/include/wx/weakref.h @@ -31,11 +31,11 @@ public: typedef T element_type; // Default ctor - wxWeakRef() : m_pobj(nullptr), m_ptbase(nullptr) { } + wxWeakRef() = default; // Ctor from the object of this type: this is needed as the template ctor // below is not used by at least g++4 when a literal NULL is used - wxWeakRef(T *pobj) : m_pobj(nullptr), m_ptbase(nullptr) + wxWeakRef(T *pobj) { this->Assign(pobj); } @@ -43,14 +43,14 @@ public: // When we have the full type here, static_cast<> will always work // (or give a straight compiler error). template - wxWeakRef(TDerived* pobj) : m_pobj(nullptr), m_ptbase(nullptr) + wxWeakRef(TDerived* pobj) { this->Assign(pobj); } // We need this copy ctor, since otherwise a default compiler (binary) copy // happens (if embedded as an object member). - wxWeakRef(const wxWeakRef& wr) : m_pobj(nullptr), m_ptbase(nullptr) + wxWeakRef(const wxWeakRef& wr) { this->Assign(wr.get()); } @@ -124,8 +124,8 @@ protected: } } - T *m_pobj; - wxTrackable *m_ptbase; + T *m_pobj = nullptr; + wxTrackable *m_ptbase = nullptr; }; @@ -137,7 +137,7 @@ template class wxWeakRefDynamic : public wxTrackerNode { public: - wxWeakRefDynamic() : m_pobj(nullptr) { } + wxWeakRefDynamic() = default; wxWeakRefDynamic(T* pobj) : m_pobj(pobj) { @@ -209,7 +209,7 @@ protected: } } - T *m_pobj; + T *m_pobj = nullptr; }; #endif // RTTI enabled diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp index 501caf9096..5f32257c6b 100644 --- a/samples/minimal/minimal.cpp +++ b/samples/minimal/minimal.cpp @@ -139,7 +139,7 @@ bool MyApp::OnInit() // frame constructor MyFrame::MyFrame(const wxString& title) - : wxFrame(NULL, wxID_ANY, title) + : wxFrame(nullptr, wxID_ANY, title) { // set the frame icon SetIcon(wxICON(sample)); diff --git a/src/unix/stackwalk.cpp b/src/unix/stackwalk.cpp index 95a0dfdd59..99dac840cb 100644 --- a/src/unix/stackwalk.cpp +++ b/src/unix/stackwalk.cpp @@ -308,7 +308,7 @@ struct ModuleInfo { } - // Name of the file containing this address, may be NULL. + // Name of the file containing this address, may be null. const char* name; // Difference between the address in the file and in memory. @@ -322,7 +322,7 @@ ModuleInfo GetModuleInfoFromAddr(void* addr) if ( !dladdr1(addr, &info, (void**)&lm, RTLD_DL_LINKMAP) ) { // Probably not worth spamming the user with even debug errors. - return ModuleInfo(NULL, 0); + return ModuleInfo(nullptr, 0); } return ModuleInfo(info.dli_fname, lm->l_addr); diff --git a/utils/wxrc/wxrc.cpp b/utils/wxrc/wxrc.cpp index 137e6978eb..9c9e6ad72c 100644 --- a/utils/wxrc/wxrc.cpp +++ b/utils/wxrc/wxrc.cpp @@ -171,7 +171,7 @@ public: m_className + wxT("(") + *m_ancestorClassNames.begin() + - wxT(" *parent=NULL){\n") + + wxT(" *parent=nullptr){\n") + wxT(" InitWidgetsFromXRC((wxWindow *)parent);\n") wxT(" }\n") wxT("};\n") @@ -180,7 +180,7 @@ public: else { file.Write(m_className + wxT("(){\n") + - wxT(" InitWidgetsFromXRC(NULL);\n") + wxT(" InitWidgetsFromXRC(nullptr);\n") wxT(" }\n") wxT("};\n"));