wxDataFormat default ctor doesn't crash for global objects

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4130 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-10-22 11:37:39 +00:00
parent 0c2b453f0a
commit 4b3d29db08
2 changed files with 38 additions and 18 deletions

View File

@@ -33,7 +33,14 @@ GdkAtom g_fileAtom = 0;
wxDataFormat::wxDataFormat() wxDataFormat::wxDataFormat()
{ {
PrepareFormats(); // do *not* call PrepareFormats() from here for 2 reasons:
//
// 1. we will have time to do it later because some other Set function
// must be called before we really need them
//
// 2. doing so prevents us from declaring global wxDataFormats because
// calling PrepareFormats (and thus gdk_atom_intern) before GDK is
// initialised will result in a crash
m_type = wxDF_INVALID; m_type = wxDF_INVALID;
m_format = (GdkAtom) 0; m_format = (GdkAtom) 0;
} }
@@ -64,6 +71,7 @@ wxDataFormat::wxDataFormat( NativeFormat format )
void wxDataFormat::SetType( wxDataFormatId type ) void wxDataFormat::SetType( wxDataFormatId type )
{ {
PrepareFormats();
m_type = type; m_type = type;
if (m_type == wxDF_TEXT) if (m_type == wxDF_TEXT)
@@ -93,6 +101,7 @@ wxString wxDataFormat::GetId() const
void wxDataFormat::SetId( NativeFormat format ) void wxDataFormat::SetId( NativeFormat format )
{ {
PrepareFormats();
m_format = format; m_format = format;
if (m_format == g_textAtom) if (m_format == g_textAtom)
@@ -109,6 +118,7 @@ void wxDataFormat::SetId( NativeFormat format )
void wxDataFormat::SetId( const wxChar *id ) void wxDataFormat::SetId( const wxChar *id )
{ {
PrepareFormats();
m_type = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
wxString tmp( id ); wxString tmp( id );
m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for? m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?

View File

@@ -33,7 +33,14 @@ GdkAtom g_fileAtom = 0;
wxDataFormat::wxDataFormat() wxDataFormat::wxDataFormat()
{ {
PrepareFormats(); // do *not* call PrepareFormats() from here for 2 reasons:
//
// 1. we will have time to do it later because some other Set function
// must be called before we really need them
//
// 2. doing so prevents us from declaring global wxDataFormats because
// calling PrepareFormats (and thus gdk_atom_intern) before GDK is
// initialised will result in a crash
m_type = wxDF_INVALID; m_type = wxDF_INVALID;
m_format = (GdkAtom) 0; m_format = (GdkAtom) 0;
} }
@@ -64,6 +71,7 @@ wxDataFormat::wxDataFormat( NativeFormat format )
void wxDataFormat::SetType( wxDataFormatId type ) void wxDataFormat::SetType( wxDataFormatId type )
{ {
PrepareFormats();
m_type = type; m_type = type;
if (m_type == wxDF_TEXT) if (m_type == wxDF_TEXT)
@@ -93,6 +101,7 @@ wxString wxDataFormat::GetId() const
void wxDataFormat::SetId( NativeFormat format ) void wxDataFormat::SetId( NativeFormat format )
{ {
PrepareFormats();
m_format = format; m_format = format;
if (m_format == g_textAtom) if (m_format == g_textAtom)
@@ -109,6 +118,7 @@ void wxDataFormat::SetId( NativeFormat format )
void wxDataFormat::SetId( const wxChar *id ) void wxDataFormat::SetId( const wxChar *id )
{ {
PrepareFormats();
m_type = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
wxString tmp( id ); wxString tmp( id );
m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for? m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?