]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filename.cpp
make sure we don't keep a focus pointer to a window that gets deleted
[wxWidgets.git] / src / common / filename.cpp
index b639fda809d9b25376703574f8db8d02778144cb..0e3653a6a3899fb2ca94aee12dc6d5bca4e611cb 100644 (file)
@@ -434,6 +434,9 @@ void wxFileName::Clear()
     m_volume =
     m_name =
     m_ext = wxEmptyString;
+
+    // we don't have any absolute path for now
+    m_relative = TRUE;
 }
 
 /* static */
@@ -638,9 +641,11 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
     // scratch space for mkstemp()
     path += _T("XXXXXX");
 
-    // can use the cast here because the length doesn't change and the string
-    // is not shared
-    int fdTemp = mkstemp((char*)(const char *)path.mb_str());
+    // we need to copy the path to the buffer in which mkstemp() can modify it
+    wxCharBuffer buf = wxConvFile.cWX2MB( path );
+
+    // cast is safe because the string length doesn't change
+    int fdTemp = mkstemp( (char*)(const char*) buf );
     if ( fdTemp == -1 )
     {
         // this might be not necessary as mkstemp() on most systems should have
@@ -649,6 +654,8 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
     }
     else // mkstemp() succeeded
     {
+        path = wxConvFile.cMB2WX( (const char*) buf );
+        
         // avoid leaking the fd
         if ( fileTemp )
         {
@@ -665,10 +672,15 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
     // same as above
     path += _T("XXXXXX");
 
-    if ( !mktemp((char *)path.mb_str()) )
+    wxCharBuffer buf = wxConvFile.cWX2MB( path );
+    if ( !mktemp( (const char*) buf ) )
     {
         path.clear();
     }
+    else
+    {
+        path = wxConvFile.cMB2WX( (const char*) buf );
+    }
 #else // !HAVE_MKTEMP (includes __DOS__)
     // generate the unique file name ourselves
     #ifndef __DOS__
@@ -1718,7 +1730,7 @@ public :
     m_type = from.m_type ;
     m_creator = from.m_creator ;
   }
-  MacDefaultExtensionRecord( char * extension , OSType type , OSType creator )
+  MacDefaultExtensionRecord( const char * extension , OSType type , OSType creator )
   {
     strncpy( m_ext , extension , kMacExtensionMaxLength ) ;
     m_ext[kMacExtensionMaxLength] = 0 ;
@@ -1745,7 +1757,7 @@ static void MacEnsureDefaultExtensionsLoaded()
 {
   if ( !gMacDefaultExtensionsInited )
   {
-    
+
     // load the default extensions
     MacDefaultExtensionRecord defaults[1] =
     {