fix some possible crashes due to uninitialized variables - thanks to Steve Hartwell for pointing me in the right direction :). Also implement wxFileTypeImpl::GetCommands.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33705 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
bab3f3eac4
commit
03271fa7a5
@ -322,11 +322,15 @@ class WXDLLEXPORT wxIcon;
|
|||||||
|
|
||||||
bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
|
bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
|
bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,10 +376,7 @@ wxFileTypeImpl::GetPrintCommand(wxString *printCmd,
|
|||||||
|
|
||||||
wxString wxFileTypeImpl::GetCommand(const wxString& verb) const
|
wxString wxFileTypeImpl::GetCommand(const wxString& verb) const
|
||||||
{
|
{
|
||||||
wxASSERT(m_manager);
|
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
|
||||||
|
|
||||||
if(!m_manager)
|
|
||||||
return wxEmptyString;
|
|
||||||
|
|
||||||
if(verb == wxT("open"))
|
if(verb == wxT("open"))
|
||||||
{
|
{
|
||||||
@ -421,10 +422,7 @@ wxString wxFileTypeImpl::GetCommand(const wxString& verb) const
|
|||||||
|
|
||||||
wxString wxFileTypeImpl::GetCommand(const wxString& verb) const
|
wxString wxFileTypeImpl::GetCommand(const wxString& verb) const
|
||||||
{
|
{
|
||||||
wxASSERT(m_manager);
|
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
|
||||||
|
|
||||||
if(!m_manager)
|
|
||||||
return wxEmptyString;
|
|
||||||
|
|
||||||
if(verb == wxT("open"))
|
if(verb == wxT("open"))
|
||||||
{
|
{
|
||||||
@ -486,8 +484,7 @@ wxString wxFileTypeImpl::GetCommand(const wxString& verb) const
|
|||||||
|
|
||||||
bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
|
bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
|
||||||
{
|
{
|
||||||
if(!m_manager)
|
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
|
||||||
return false;
|
|
||||||
|
|
||||||
ICMapEntry entry;
|
ICMapEntry entry;
|
||||||
ICGetMapEntry( (ICInstance) m_manager->m_hIC,
|
ICGetMapEntry( (ICInstance) m_manager->m_hIC,
|
||||||
@ -502,8 +499,7 @@ bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
|
|||||||
|
|
||||||
bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
|
bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
|
||||||
{
|
{
|
||||||
if(!m_manager)
|
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
|
||||||
return false;
|
|
||||||
|
|
||||||
ICMapEntry entry;
|
ICMapEntry entry;
|
||||||
ICGetMapEntry( (ICInstance) m_manager->m_hIC,
|
ICGetMapEntry( (ICInstance) m_manager->m_hIC,
|
||||||
@ -530,14 +526,15 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
|
|||||||
|
|
||||||
bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
|
bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
|
||||||
|
|
||||||
// no such file type or no value or incorrect icon entry
|
// no such file type or no value or incorrect icon entry
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileTypeImpl::GetDescription(wxString *desc) const
|
bool wxFileTypeImpl::GetDescription(wxString *desc) const
|
||||||
{
|
{
|
||||||
if(!m_manager)
|
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
|
||||||
return false;
|
|
||||||
|
|
||||||
ICMapEntry entry;
|
ICMapEntry entry;
|
||||||
ICGetMapEntry( (ICInstance) m_manager->m_hIC,
|
ICGetMapEntry( (ICInstance) m_manager->m_hIC,
|
||||||
@ -551,8 +548,19 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const
|
|||||||
size_t wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
|
size_t wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
|
||||||
const wxFileType::MessageParameters& params) const
|
const wxFileType::MessageParameters& params) const
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
|
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
|
||||||
return 0;
|
|
||||||
|
wxString sCommand;
|
||||||
|
size_t ulCount = 0;
|
||||||
|
|
||||||
|
if(GetOpenCommand(&sCommand, params))
|
||||||
|
{
|
||||||
|
verbs->Add(wxString(wxT("open")));
|
||||||
|
commands->Add(sCommand);
|
||||||
|
++ulCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ulCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
|
void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
|
||||||
@ -570,6 +578,7 @@ void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extra
|
|||||||
{
|
{
|
||||||
wxLogDebug(wxT("Could not initialize wxMimeTypesManager!"));
|
wxLogDebug(wxT("Could not initialize wxMimeTypesManager!"));
|
||||||
wxASSERT( false );
|
wxASSERT( false );
|
||||||
|
m_hIC = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,6 +642,11 @@ void wxMimeTypesManagerImpl::ClearData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Q) Iterating through the map - why does it use if (err == noErr) instead of just asserting?
|
||||||
|
// A) Some intermediate indexes are bad while subsequent ones may be good. Its wierd, I know.
|
||||||
|
//
|
||||||
|
|
||||||
// extension -> file type
|
// extension -> file type
|
||||||
wxFileType* wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
|
wxFileType* wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
|
||||||
{
|
{
|
||||||
@ -640,7 +654,6 @@ wxFileType* wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
|
|||||||
|
|
||||||
//low level functions - iterate through the database
|
//low level functions - iterate through the database
|
||||||
ICMapEntry entry;
|
ICMapEntry entry;
|
||||||
wxFileType* pFileType;
|
|
||||||
long pos;
|
long pos;
|
||||||
|
|
||||||
for(long i = 1; i <= m_lCount; ++i)
|
for(long i = 1; i <= m_lCount; ++i)
|
||||||
@ -652,14 +665,14 @@ wxFileType* wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
|
|||||||
wxString sCurrentExtension = wxMacMakeStringFromPascal(entry.extension);
|
wxString sCurrentExtension = wxMacMakeStringFromPascal(entry.extension);
|
||||||
if( sCurrentExtension.Right(sCurrentExtension.Length()-1) == e ) //entry has period in it
|
if( sCurrentExtension.Right(sCurrentExtension.Length()-1) == e ) //entry has period in it
|
||||||
{
|
{
|
||||||
pFileType = new wxFileType();
|
wxFileType* pFileType = new wxFileType();
|
||||||
pFileType->m_impl->Init((wxMimeTypesManagerImpl*)this, pos);
|
pFileType->m_impl->Init((wxMimeTypesManagerImpl*)this, pos);
|
||||||
break;
|
return pFileType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pFileType;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MIME type -> extension -> file type
|
// MIME type -> extension -> file type
|
||||||
@ -669,8 +682,6 @@ wxFileType* wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mime
|
|||||||
|
|
||||||
//low level functions - iterate through the database
|
//low level functions - iterate through the database
|
||||||
ICMapEntry entry;
|
ICMapEntry entry;
|
||||||
wxFileType* pFileType;
|
|
||||||
|
|
||||||
long pos;
|
long pos;
|
||||||
|
|
||||||
for(long i = 1; i <= m_lCount; ++i)
|
for(long i = 1; i <= m_lCount; ++i)
|
||||||
@ -682,14 +693,14 @@ wxFileType* wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mime
|
|||||||
{
|
{
|
||||||
if( wxMacMakeStringFromPascal(entry.MIMEType) == mimeType)
|
if( wxMacMakeStringFromPascal(entry.MIMEType) == mimeType)
|
||||||
{
|
{
|
||||||
pFileType = new wxFileType();
|
wxFileType* pFileType = new wxFileType();
|
||||||
pFileType->m_impl->Init((wxMimeTypesManagerImpl*)this, pos);
|
pFileType->m_impl->Init((wxMimeTypesManagerImpl*)this, pos);
|
||||||
break;
|
return pFileType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pFileType;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
|
size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
|
||||||
@ -698,8 +709,8 @@ size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
|
|||||||
|
|
||||||
//low level functions - iterate through the database
|
//low level functions - iterate through the database
|
||||||
ICMapEntry entry;
|
ICMapEntry entry;
|
||||||
|
|
||||||
long pos;
|
long pos;
|
||||||
|
|
||||||
long lStartCount = (long) mimetypes.GetCount();
|
long lStartCount = (long) mimetypes.GetCount();
|
||||||
|
|
||||||
for(long i = 1; i <= m_lCount; ++i)
|
for(long i = 1; i <= m_lCount; ++i)
|
||||||
|
Loading…
Reference in New Issue
Block a user