Merge branch 'nullptr'

Use nullptr instead of NULL in the code, comments and the documentation.

See #22881.
This commit is contained in:
Vadim Zeitlin 2022-10-18 18:34:07 +02:00
commit 9f46e67eec
1846 changed files with 13723 additions and 13742 deletions

View file

@ -73,7 +73,7 @@ DO:
It's also very important to make a consistent use of the ALIASES
defined by wxWidgets' Doxyfile. Open that file for more info.
- when you write true, false and NULL with their C++ semantic meaning,
- when you write true, false and nullptr with their C++ semantic meaning,
then use the @true, @false and @NULL commands.
- separate different paragraphs with an empty comment line.

View file

@ -140,7 +140,7 @@ ALIASES += header{1}="Include file:^^ \verbatim #include <\1> \endverbatim"
# some formatting aliases
ALIASES += true="<span class='literal'>true</span>"
ALIASES += false="<span class='literal'>false</span>"
ALIASES += NULL="<span class='literal'>NULL</span>"
ALIASES += NULL="<span class='literal'>nullptr</span>"
ALIASES += NUL="<span class='literal'>NUL</span>"
# NOTE: these are important as you can't write in the docs

View file

@ -189,7 +189,7 @@ See @ref overview_config for the descriptions of all features of this class.
This sample shows how to use wxDebugReport class to
generate a debug report in case of a program crash or otherwise. On start up,
it proposes to either crash itself (by dereferencing a NULL pointer) or
it proposes to either crash itself (by dereferencing a @NULL) or
generate debug report without doing it. Next it initializes the debug report
with standard information adding a custom file to it (just a timestamp) and
allows to view the information gathered using

View file

@ -45,7 +45,7 @@ wxIMPLEMENT_APP(DerivedApp);
bool DerivedApp::OnInit()
{
wxFrame *the_frame = new wxFrame(NULL, ID_MYFRAME, argv[0]);
wxFrame *the_frame = new wxFrame(nullptr, ID_MYFRAME, argv[0]);
...
the_frame->Show(true);

View file

@ -73,7 +73,7 @@ auto_ptr<wxZipEntry> entry;
wxFFileInputStream in(wxT("test.zip"));
wxZipInputStream zip(in);
while (entry.reset(zip.GetNextEntry()), entry.get() != NULL)
while (entry.reset(zip.GetNextEntry()), entry.get() != nullptr)
{
// access meta-data
wxString name = entry->GetName();
@ -114,7 +114,7 @@ auto_ptr<wxZipEntry> entry;
outzip.CopyArchiveMetaData(inzip);
// call CopyEntry for each entry except those matching the pattern
while (entry.reset(inzip.GetNextEntry()), entry.get() != NULL)
while (entry.reset(inzip.GetNextEntry()), entry.get() != nullptr)
if (!entry->GetName().Matches(wxT("*.txt")))
if (!outzip.CopyEntry(entry.release(), inzip))
break;
@ -165,9 +165,9 @@ do
{
entry.reset(zip.GetNextEntry());
}
while (entry.get() != NULL && entry->GetInternalName() != name);
while (entry.get() != nullptr && entry->GetInternalName() != name);
if (entry.get() != NULL)
if (entry.get() != nullptr)
{
// read the entry's data...
}
@ -189,7 +189,7 @@ wxFFileInputStream in(wxT("test.zip"));
wxZipInputStream zip(in);
// load the zip catalog
while ((entry = zip.GetNextEntry()) != NULL)
while ((entry = zip.GetNextEntry()) != nullptr)
{
wxZipEntry*& current = cat[entry->GetInternalName()];
// some archive formats can have multiple entries with the same name
@ -296,7 +296,7 @@ if (in->IsOk())
auto_ptr<wxArchiveEntry> entry;
// list the contents of the archive
while ((entry.reset(arc->GetNextEntry())), entry.get() != NULL)
while ((entry.reset(arc->GetNextEntry())), entry.get() != nullptr)
std::wcout << entry->GetName() << "\n";
}
else
@ -381,7 +381,7 @@ auto_ptr<wxArchiveEntry> entry;
outarc->CopyArchiveMetaData(*arc);
while (entry.reset(arc->GetNextEntry()), entry.get() != NULL)
while (entry.reset(arc->GetNextEntry()), entry.get() != nullptr)
{
if (entry->GetName() == from)
entry->SetName(to);
@ -418,7 +418,7 @@ MyNotifier notifier;
outarc->CopyArchiveMetaData(*arc);
while (entry.reset(arc->GetNextEntry()), entry.get() != NULL)
while (entry.reset(arc->GetNextEntry()), entry.get() != nullptr)
{
entry->SetNotifier(notifier);
if (!outarc->CopyEntry(entry.release(), *arc))

View file

@ -81,7 +81,7 @@ Example of using an assertion macro:
@code
void GetTheAnswer(int *p)
{
wxCHECK_RET( p, "pointer can't be NULL in GetTheAnswer()" );
wxCHECK_RET( p, "pointer can't be null in GetTheAnswer()" );
*p = 42;
};
@ -89,7 +89,7 @@ void GetTheAnswer(int *p)
If the condition is false, i.e. @c p is @NULL, the assertion handler is called
and, in any case (even when wxDEBUG_LEVEL is 0), the function returns without
dereferencing the NULL pointer on the next line thus avoiding a crash.
dereferencing the null pointer on the next line thus avoiding a crash.
The default assertion handler behaviour depends on whether the application
using wxWidgets was compiled in release build (with @c NDEBUG defined) or debug

View file

@ -127,7 +127,7 @@ window. Both have to be bound to the frame with respective calls.
@code
MyFrame::MyFrame()
: wxFrame(NULL, wxID_ANY, "Hello World")
: wxFrame(nullptr, wxID_ANY, "Hello World")
{
wxMenu *menuFile = new wxMenu;
menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
@ -272,7 +272,7 @@ bool MyApp::OnInit()
}
MyFrame::MyFrame()
: wxFrame(NULL, wxID_ANY, "Hello World")
: wxFrame(nullptr, wxID_ANY, "Hello World")
{
wxMenu *menuFile = new wxMenu;
menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",

View file

@ -200,7 +200,7 @@ connection = (MyConnection *)client->MakeConnection(hostName, server, "IPC TEST"
if (!connection)
{
wxMessageBox("Failed to make connection to server", "Client Demo Error");
return NULL;
return nullptr;
}
connection->StartAdvise("Item");

View file

@ -270,7 +270,7 @@ A very simple example:
// Using wxChar* array
//
const wxChar* arrayDiet[] =
{ wxT("Herbivore"), wxT("Carnivore"), wxT("Omnivore"), NULL };
{ wxT("Herbivore"), wxT("Carnivore"), wxT("Omnivore"), nullptr };
pg->Append( new wxEnumProperty("Diet",
wxPG_LABEL,
@ -348,7 +348,7 @@ wxFlagsProperty has similar construction:
@code
const wxChar* flags_prop_labels[] = { wxT("wxICONIZE"),
wxT("wxCAPTION"), wxT("wxMINIMIZE_BOX"), wxT("wxMAXIMIZE_BOX"), NULL };
wxT("wxCAPTION"), wxT("wxMINIMIZE_BOX"), wxT("wxMAXIMIZE_BOX"), nullptr };
// this value array would be optional if values matched string indexes
long flags_prop_values[] = { wxICONIZE, wxCAPTION, wxMINIMIZE_BOX,

View file

@ -71,7 +71,7 @@ Example:
// it's a single Unicode code-point encoded as:
// - a UTF16 surrogate pair under Windows
// - a UTF8 multiple-bytes sequence under Linux
// (without considering the final NULL)
// (without considering the final NUL)
wxPrintf("wxString reports a length of %d character(s)", test.length());
// prints "wxString reports a length of 1 character(s)" on Linux
@ -88,7 +88,7 @@ Example:
// they are 3 Unicode code-points encoded as:
// - 3 UTF16 code units under Windows
// - 6 UTF8 code units under Linux
// (without considering the final NULL)
// (without considering the final NUL)
wxPrintf("wxString reports a length of %d character(s)", test2.length());
// prints "wxString reports a length of 3 character(s)" on Linux
@ -96,7 +96,7 @@ Example:
@endcode
To better explain what stated above, consider the second string of the example
above; it's composed by 3 characters and the final @c NULL:
above; it's composed by 3 characters and the final @NUL:
@image html overview_wxstring_encoding.png
@ -303,12 +303,12 @@ for (i = s.begin(); i != s.end(); ++i)
As most programs use character strings, the standard C library provides quite
a few functions to work with them. Unfortunately, some of them have rather
counter-intuitive behaviour (like @c strncpy() which doesn't always terminate
the resulting string with a @NULL) and are in general not very safe (passing
the resulting string with a @NUL) and are in general not very safe (passing
@NULL to them will probably lead to program crash). Moreover, some very useful
functions are not standard at all. This is why in addition to all wxString
functions, there are also a few global string functions which try to correct
these problems: wxIsEmpty() verifies whether the string is empty (returning
@true for @NULL pointers), wxStrlen() also handles @NULL correctly and returns
@true for @NULL), wxStrlen() also handles @NULL correctly and returns
0 for them and wxStricmp() is just a platform-independent version of
case-insensitive string comparison function known either as @c stricmp() or
@c strcasecmp() on different platforms.

View file

@ -142,7 +142,7 @@ This is how you would use the above simple dialog in your code.
void MyClass::ShowDialog()
{
wxDialog dlg;
if (wxXmlResource::Get()->LoadDialog(&dlg, NULL, "SimpleDialog"))
if (wxXmlResource::Get()->LoadDialog(&dlg, nullptr, "SimpleDialog"))
dlg.ShowModal();
}
@endcode
@ -165,7 +165,7 @@ the XRCCTRL macro to get a pointer to the child. To expand the previous code:
void MyClass::ShowDialog()
{
wxDialog dlg;
if (!wxXmlResource::Get()->LoadDialog(&dlg, NULL, "SimpleDialog"))
if (!wxXmlResource::Get()->LoadDialog(&dlg, nullptr, "SimpleDialog"))
return;
wxTextCtrl* pText = XRCCTRL(dlg, "text", wxTextCtrl);
@ -195,7 +195,7 @@ control to the XRCID macro:
void MyClass::ShowDialog()
{
wxDialog dlg;
if (!wxXmlResource::Get()->LoadDialog(&dlg, NULL, "SimpleDialog"))
if (!wxXmlResource::Get()->LoadDialog(&dlg, nullptr, "SimpleDialog"))
return;
XRCCTRL(dlg, "text", wxTextCtrl)->Bind(wxEVT_TEXT,
@ -367,7 +367,7 @@ protected:
private:
void InitWidgetsFromXRC()
{
wxXmlResource::Get()->LoadObject(this, NULL, "TestWnd", "wxFrame");
wxXmlResource::Get()->LoadObject(this, nullptr, "TestWnd", "wxFrame");
A = XRCCTRL(*this, "A", wxTextCtrl);
B = XRCCTRL(*this, "B", wxButton);
}

View file

@ -59,7 +59,7 @@ The approach chosen was to use templates to help inherit QObject's (QWidget), pr
### Delete later
Both templates also have some safety checks to avoid invalid spurious access to deleted wx objects (using a special pointer to the wx instance stored in the Qt object, that is reset to NULL when the wx counterpart is marked to deletion).
Both templates also have some safety checks to avoid invalid spurious access to deleted wx objects (using a special pointer to the wx instance stored in the Qt object, that is reset to @NULL when the wx counterpart is marked to deletion).
This is due that in some situations, Qt object could still be referenced in the Qt event queue, so it cannot be removed immediately.