check for empty data pointer in Len() and Empty()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@766 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1c4a764c98
commit
ecadfc3f5a
@ -254,13 +254,13 @@ public:
|
|||||||
/** @name generic attributes & operations */
|
/** @name generic attributes & operations */
|
||||||
//@{
|
//@{
|
||||||
/// as standard strlen()
|
/// as standard strlen()
|
||||||
size_t Len() const { return GetStringData()->nDataLength; }
|
size_t Len() const { return GetStringData() ? GetStringData()->nDataLength : 0; }
|
||||||
/// string contains any characters?
|
/// string contains any characters?
|
||||||
bool IsEmpty() const { return Len() == 0; }
|
bool IsEmpty() const { return Len() == 0; }
|
||||||
/// reinitialize string (and free data!)
|
/// reinitialize string (and free data!)
|
||||||
void Empty()
|
void Empty()
|
||||||
{
|
{
|
||||||
if ( GetStringData()->nDataLength != 0 )
|
if ( GetStringData() && GetStringData()->nDataLength != 0 )
|
||||||
Reinit();
|
Reinit();
|
||||||
|
|
||||||
wxASSERT( GetStringData()->nDataLength == 0 );
|
wxASSERT( GetStringData()->nDataLength == 0 );
|
||||||
|
Loading…
Reference in New Issue
Block a user