Showing posts with label KDE. Show all posts
Showing posts with label KDE. Show all posts

Friday, 12 August 2011

SaveFileDialog bug under Mono .NET in KDE

Found a bug... in Mono combined with KDE.  So, today I released a little internal tool on Windows, some of our department run Linux, and the application is writtein in C#, so I figured I'd just cross check it on Mono and release it as a Mono flavour executable too.

All seemed fine until the very last step, where the generated output is saved.  The application pops up a "SaveFileDialog" a very simple, standard System.Windows.Forms dialog, the code shows this and used the resulting Filename to save some data.

Under Windows on Microsoft .net Framework 3.5 it was fine, Under Mono within Gnome it was fine.  However, under Mono on KDE I was getting a really strange result, it kept crashing in a routine (wholly unrelated to the actual issue I found) because the file name being returned under KDE was not lead with a directory separator character (as required in Linux).

So, the path under windows might come back as "C:\Data\File.txt" in Ubuntu it comes back as "/home/data/file.txt" but under KDE it was coming back as "home/data/file.txt".  Meaning that the data files were being placed in the wrong location, they were going into a path relative to the applications runtime path.

Meaning the next time I ran the application, from a different root directory or as a different user, or from a folder which did not allow file creation, I could not find my data, I got undefined program behaviour and basically data-wise everything went pear shaped.

I solved this with a simple check:


private void SaveFile (string psFilename)
{
// Save the file
}


private void PathExample(string psThePath)
{
string lsPath = psThePath;
#ifndef WIN32
if ( !lsPath.StartsWith ("" + Path.DirectorySeparatorChar) )
{
lsPath = Path.DirectorySeparatorChar + lsPath;
}
#endif
SaveFile (lsPath);
}

public void SaveDataAs ()
{
SaveFileDialog lsfdDialog = new SaveFileDialog();
if ( lsfd.ShowDialog() == DialogResult.OK )
{
PathExample(lsfdDialog.Filename);
}
lsfdDialog.Dispose();
}

So, this is a problem with the current (as of writing) Mono on KDE, under Kubuntu 11.04, don't fall foul of it.

Wednesday, 18 August 2010

My Plasma has Passed Away

Well, I dunno what I've done, but on my Linux Virtual Machine Host box I've managed to remove the task bar... you know the bit at the bottom showing you what apps you have running... well, it is AWOL...

I'm going to be reinstalling that box at some point this weekend, fitting some of my older 120GB disks into her and fitting 2GB more RAM - YAY!...

But, still, a missing task bar is a bit of a pain in the arse.

I've inserted a fixed widget to show me my applications, but I miss my task bar...

So, anyone coming to play with Kubuntu on KDE with Plasma desktop extensions, when it has all done installing carefully right click on everything and lock it in place.