Ticket #11541 (closed defect: fixed)
Fix for opening of multiple document templates not working on OSX
| Reported by: | SnowLeopard | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9.1 |
| Component: | wxOSX-Cocoa | Version: | 2.9-svn |
| Keywords: | OSX document templates | Cc: | |
| Blocked By: | Patch: | yes | |
| Blocking: |
Description
Say that you have a program with more than one document template (e.g., files with the DOC1 and DOC2 extensions). When a wxID_OPEN event is fired, the OSX file open dialog will appear and you will be able to select any file that matches the extensions for your templates (i.e., you can select either DOC1 or DOC2). Note how this is different from Windows where you have a file filter and you need to change that filter to select different document types--this is because the OSX file open doesn't have a file filter combobox like Windows. It just clumps all allowable file types into one filter.
Here is the problem--if you select any document type other than the first one (e.g., select DOC2), then the program will always load it as a DOC1 file. The culprit is "wxDocManager::SelectDocumentPath" in docview.cpp:
if ( FilterIndex != -1 )
theTemplate = templates[FilterIndex];
On OSX, no matter what doc type you select, "FilterIndex" will always be zero. If you wrap this logic in a "#ifndef WXMAC" block, then that fixes it because then FindTemplateForPath is called and selects the proper template (see attached patch).

