[Gtkradiant] File Saving in Windows Vista / 7 - fixed!

Willi willi at schinmeyer.de
Fri Mar 12 09:03:02 CST 2010


I figured out why saving fails in Vista and 7!

In gtkmisc.cpp there's
const char* file_dialog (void *parent, gboolean open, const char* title, 
const char* path, const char* pattern, const char *baseSubDir)
and somewhere around line 1250 there's the windows part.

Reading the MSDN I really wonder why the customfilter part ever worked. 
It's not used they way it's intended to be used and I don't know why it 
ever worked... Well, since Vista it doesn't work anymore. Why?
type = typelist.GetTypeForWin32Filter(customfilter+1);
sets type to an invalid (empty) type. This results in the file being 
stripped from its extension later in the function and 
CSynapseClientRadiant::ExportMap() being unable to choose a format based 
on the (missing) extension. (Hence the WARNING: no module found for map 
interface type ''.)

A workaround is to disable the "Win32 file load dialog" in the layout 
section of the preferences since the GTK dialog works. That way you can 
also get 1.4 to save in Vista and 7.

I also found a fix. Customfilter seem to be meant for users to set their 
own filters and have nothing to do with what the user selected (unless 
it's a custom filter).
In order to get the selected filter (that's what we want here, right?) 
the nFilterIndex should be checked after calling GetSaveFileName().

I thus removed everything having to do with customfilters and added 
support for using the index:

    * In *radiant/gtkmisc.cpp*:
    * In the function *file_dialog()*:
    * I deleted the variable
      char customfilter[FILEDLG_CUSTOM_FILTER_LENGTH];
    * and its assignment
      customfilter[0] = customfilter[1] = customfilter[2] = '\0';
    * ofn.nFilterIndex should always be set to 0, so take it out of the
      if(pattern) block and delete the else block.
    * The whole else block can be deleted.
    * Since we don't use custom filters we can delete
      ofn.lpstrCustomFilter = customfilter;
    * the if(pattern != NULL) needs to be changed, too. Replace
      type = typelist.GetTypeForWin32Filter(customfilter+1);
      with
      type = typelist.GetTypeFromIndex(ofn.nFilterIndex-1);
    * The GetTypeFromIndex() method does not yet exist. We need to add
      it to CFileType somewhere in the public scope:
         filetype_t GetTypeFromIndex(int index)
         {
             if(index < m_nTypes && index >= 0)
                 return filetype_t(m_pTypes[index].m_name.c_str(),
      m_pTypes[index].m_pattern.c_str());
             return filetype_t();
         }

That fixes the save problem. At least in Windows 7 - I'm too lazy to 
switch to XP and see if it still works there...

And why are most plugins not active?

Willi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://zerowing.idsoftware.com/pipermail/gtkradiant/attachments/20100312/2285d370/attachment.htm 


More information about the Gtkradiant mailing list