Merge remote-tracking branch 'github/more-null-fixes'

More NULL-related fixes.

See #23459.
This commit is contained in:
Vadim Zeitlin 2023-04-18 14:20:07 +02:00
commit be1fabcda3
5 changed files with 15 additions and 15 deletions

View file

@ -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

View file

@ -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 <class TDerived>
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<T>& wr) : m_pobj(nullptr), m_ptbase(nullptr)
wxWeakRef(const wxWeakRef<T>& 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 T>
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

View file

@ -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));

View file

@ -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);

View file

@ -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"));