Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » FileSel&FileList, Path » BUG + FIX: FileSelNative shows default filename as some trash characters
BUG + FIX: FileSelNative shows default filename as some trash characters [message #58798] Sat, 03 September 2022 04:19 Go to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
On windows, using MSC it shows trash, with CLANG: nothing.

To reproduce and test:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

GUI_APP_MAIN
{
	FileSelNative fs;
	fs
		.Type(t_("CSV files"), "*.csv")
		.AllFilesType()
		.ActiveDir("c:\\tmp")
		.DefaultExt("csv")
		.Set("ABCDEF.csv");
	if(!fs.ExecuteSaveAs())
		return;
	
	PromptOK("Filename:&&" + DeQtf(~fs));

}


The fix:
@@ -191,33 +191,33 @@ bool FileSelNative::Execute(bool open, const char *dlgtitle) {
 	ofn.lpstrInitialDir = W32(activedir);
 	ofn.lpfnHook = sCenterHook;
 	int bufsize = ofn.nMaxFile = (multi ? 32000 : _MAX_PATH);
 	Buffer<char16> buffer(bufsize);
 	*(ofn.lpstrFile = buffer) = 0;
 	if(!filename.IsEmpty())
 	{
-		String out;
+		Vector<char16> out;
 		for(int i = 0; i < filename.GetCount(); i++)
 		{
 			if(*ofn.lpstrInitialDir == 0 && FindFile().Search(AppendFileName(GetFileDirectory(filename[i]), "*")))
 				ofn.lpstrInitialDir = W32(GetFileDirectory(filename[i]));
 			if(!open || FileExists(filename[i]))
 			{
 				String fn = GetFileName(filename[i]);
 				if(!IsNull(fn))
 				{
 					if(multi && fn.Find(' ') >= 0)
-						out << W32(String() << '\"' << fn << '\"');
+						out.Append( ToSystemCharsetW('\"' + fn + '\"'));
 					else
-						out << W32(fn);
-					out.Cat(0);
+						out.Append(ToSystemCharsetW(fn));
+					out.Add(0);
 				}
 			}
 		}
-		int l = min(out.GetLength(), bufsize - 1);
+		int l = min(out.GetCount()*2, bufsize - 1);
 		memcpy(buffer, out, l + 1);
 	}
 
 	if(dlgtitle)
 		ofn.lpstrTitle = W32(dlgtitle);
 	else if(open)
 		ofn.lpstrTitle = W32(t_("Open.."));

[Updated on: Sat, 03 September 2022 04:20]

Report message to a moderator

Re: BUG + FIX: FileSelNative shows default filename as some trash characters [message #58799 is a reply to message #58798] Sat, 03 September 2022 10:42 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Zsolt,

Can you create Pull Request for that change? I know from my own experience that some changes on forum after some time might get lost. The procedure of creating PR is easy, you creating your own form with separate branch and then create PR. You can find more information about our GIT repository on this site.

Klugier


U++ - one framework to rule them all.
Re: BUG + FIX: FileSelNative shows default filename as some trash characters [message #58800 is a reply to message #58799] Sat, 03 September 2022 16:57 Go to previous message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
Hello, I created one:
https://github.com/ultimatepp/ultimatepp/pull/90
Previous Topic: FileSel takes quite a lot of CPU on Windows
Next Topic: FileSel in Local Network not show shared folders
Goto Forum:
  


Current Time: Thu Mar 28 22:40:35 CET 2024

Total time taken to generate the page: 0.01122 seconds