[RhinoCommon] SaveFileDialog does not handle Filter correctly

(Menno Deij - van Rijswijk) #1

When I run a save file dialog like below, the drop down box of the file type shows erroneous characters, sometimes on many entries.

Rhino.UI.SaveFileDialog d = new Rhino.UI.SaveFileDialog();
d.Filter = "Hydrostatics Report (.lis)|*.lis";

But, if I append a pipe symbol | to the end of the filter, this does not happen. I’m guessing here, but it seems that the system uses C-style string scanning, does not find the final | and keeps going in a buffer overrrun?

Rhino.UI.SaveFileDialog d = new Rhino.UI.SaveFileDialog();
d.Filter = "Hydrostatics Report (.lis)|*.lis|"; // this works, but is not a valid Filter string according to MSDN and does not work in the winforms SaveDialog

(Menno Deij - van Rijswijk) #2

If this uses MFC under water, I think the convention there is to use a double null terminated string of null- terminated strings, “stringstring”.

(Dale Fugier) #3

The standard convention for teminating a filter string is to append two pipe characters. Thus, your example would look like this:

"Hydrostatics Report (.lis)|*.lis||"


Rhino.UI.SaveFileDialog d = new Rhino.UI.SaveFileDialog();
d.Filter = "Hydrostatics Report (.lis)|*.lis||";

(Menno Deij - van Rijswijk) #4

I’m not sure where the ‘standard convention’ you mention is defined, but it would be nice if you followed the MSDN SaveFileDialog convention (see http://msdn.microsoft.com/en-us/library/system.windows.controls.savefiledialog.filter(v=vs.95).aspx), which does not use a double pipe terminator. If I use such a double pipe terminator on a winforms SaveFileDialog, the result looks like this, with an additional, emtpy, file type.

(Dale Fugier) #5

I will add your request to the pile. In the mean time, you might just want to use System.Windows.Forms.SaveFileDialog.

(John Morse) #6

SR 5 Will support filter strings ending with “|”, “||” or no “|” at all.

(Menno Deij - van Rijswijk) #7

It’s great to see that even “old” issues are being followed up. Thanks all :slight_smile:

(Brian Gillespie) #8

RH-28815 is fixed in the latest Service Release Candidate