X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ff7dbb27d495cc5e7369016aaa1d7449968368aa..7c60222510bc5e197b12f153c4bf05db66cb0f4a:/src/osx/cocoa/filedlg.mm?ds=sidebyside diff --git a/src/osx/cocoa/filedlg.mm b/src/osx/cocoa/filedlg.mm index d08d3a3c3e..40d4f4645f 100644 --- a/src/osx/cocoa/filedlg.mm +++ b/src/osx/cocoa/filedlg.mm @@ -34,9 +34,11 @@ #include "wx/filename.h" #include "wx/tokenzr.h" +#include "wx/evtloop.h" #include "wx/osx/private.h" #include "wx/sysopt.h" +#include "wx/modalhook.h" #include @@ -194,6 +196,7 @@ wxFileDialog::wxFileDialog( m_filterIndex = -1; m_sheetDelegate = [[ModalDialogDelegate alloc] init]; [(ModalDialogDelegate*)m_sheetDelegate setImplementation: this]; + m_delegate = nil; } wxFileDialog::~wxFileDialog() @@ -395,7 +398,7 @@ wxWindow* wxFileDialog::CreateFilterPanel(wxWindow *extracontrol) if ( m_firstFileTypeFilter >= 0 ) m_filterChoice->SetSelection(m_firstFileTypeFilter); } - m_filterChoice->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(wxFileDialog::OnFilterSelected), NULL, this); + m_filterChoice->Connect(wxEVT_CHOICE, wxCommandEventHandler(wxFileDialog::OnFilterSelected), NULL, this); } if(extracontrol) @@ -446,6 +449,11 @@ bool wxFileDialog::CheckFile( const wxString& filename ) void wxFileDialog::SetupExtraControls(WXWindow nativeWindow) { NSSavePanel* panel = (NSSavePanel*) nativeWindow; + // for sandboxed app we cannot access the outer structures + // this leads to problems with extra controls, so as a temporary + // workaround for crashes we don't support those yet + if ( [panel contentView] == nil ) + return; wxNonOwnedWindow::Create( GetParent(), nativeWindow ); wxWindow* extracontrol = NULL; @@ -456,7 +464,6 @@ void wxFileDialog::SetupExtraControls(WXWindow nativeWindow) } NSView* accView = nil; - m_delegate = nil; if ( m_useFileTypeFilter ) { @@ -494,6 +501,10 @@ void wxFileDialog::SetupExtraControls(WXWindow nativeWindow) int wxFileDialog::ShowModal() { + WX_HOOK_MODAL_DIALOG(); + + wxCFEventLoopPauseIdleEvents pause; + wxMacAutoreleasePool autoreleasepool; wxCFStringRef cf( m_message ); @@ -645,7 +656,7 @@ void wxFileDialog::ModalFinishedCallback(void* panel, int returnCode) NSSavePanel* sPanel = (NSSavePanel*)panel; result = wxID_OK; - m_path = wxCFStringRef::AsString([sPanel filename]); + m_path = wxCFStringRef::AsStringWithNormalizationFormC([sPanel filename]); m_fileName = wxFileNameFromPath(m_path); m_dir = wxPathOnly( m_path ); if (m_filterChoice) @@ -664,7 +675,7 @@ void wxFileDialog::ModalFinishedCallback(void* panel, int returnCode) NSArray* filenames = [oPanel filenames]; for ( size_t i = 0 ; i < [filenames count] ; ++ i ) { - wxString fnstr = wxCFStringRef::AsString([filenames objectAtIndex:i]); + wxString fnstr = wxCFStringRef::AsStringWithNormalizationFormC([filenames objectAtIndex:i]); m_paths.Add( fnstr ); m_fileNames.Add( wxFileNameFromPath(fnstr) ); if ( i == 0 ) @@ -687,7 +698,9 @@ void wxFileDialog::ModalFinishedCallback(void* panel, int returnCode) if (GetModality() == wxDIALOG_MODALITY_WINDOW_MODAL) SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED ); - UnsubclassWin(); + // workaround for sandboxed app, see above + if ( m_isNativeWindowWrapper ) + UnsubclassWin(); [(NSSavePanel*) panel setAccessoryView:nil]; }