Work around mono crashing on Rows.Clear()

Mono will crash if you do a Rows.Clear() and the first row isnt visible.  To
work around this, when running under mono force scroll to [0,0] cell before
issuing the Clear().

https://bugzilla.xamarin.com/show_bug.cgi?id=24372

Renamed Settings.MonoFileIO to Settings.IsUnix
Created Settings.IsMono
This commit is contained in:
Jim Westfall
2014-11-13 17:24:53 -08:00
parent 09ccdd7e10
commit b54610c2f6
5 changed files with 46 additions and 20 deletions

View File

@@ -444,6 +444,15 @@ namespace ROMVault2
private void DatSetSelected(RvBase cf)
{
DirTree.Refresh();
if (Settings.IsMono)
{
if (GameGrid.RowCount > 0)
GameGrid.CurrentCell = GameGrid[0,0];
if (RomGrid.RowCount > 0)
RomGrid.CurrentCell = RomGrid[0,0];
}
GameGrid.Rows.Clear();
RomGrid.Rows.Clear();
@@ -579,6 +588,15 @@ namespace ROMVault2
lblDITRomsUnknown.Text = (tDir.DirStatus.CountUnknown() + tDir.DirStatus.CountInToSort()).ToString(CultureInfo.InvariantCulture);
_updatingGameGrid = true;
if (Settings.IsMono)
{
if (GameGrid.RowCount > 0)
GameGrid.CurrentCell = GameGrid[0,0];
if (RomGrid.RowCount > 0)
RomGrid.CurrentCell = RomGrid[0,0];
}
GameGrid.Rows.Clear();
RomGrid.Rows.Clear();
@@ -1160,6 +1178,9 @@ namespace ROMVault2
}
}
if (Settings.IsMono && RomGrid.RowCount > 0)
RomGrid.CurrentCell = RomGrid[0,0];
RomGrid.Rows.Clear();
AddDir(tGame, "");
GC.Collect();

View File

@@ -35,6 +35,9 @@ namespace ROMVault2
private void UpdateGrid()
{
if (Settings.IsMono && DataGridGames.RowCount > 0)
DataGridGames.CurrentCell = DataGridGames[0,0];
DataGridGames.Rows.Clear();
foreach (DirMap t in Settings.DirPathMap)
{

View File

@@ -57,7 +57,7 @@ namespace ROMVault2.IO
FullName = path;
Name = Path.GetFileName(path);
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.FileInfo fi = new System.IO.FileInfo(path);
@@ -94,7 +94,7 @@ namespace ROMVault2.IO
FullName = path;
Name = Path.GetFileName(path);
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.DirectoryInfo fi = new System.IO.DirectoryInfo(path);
@@ -123,7 +123,7 @@ namespace ROMVault2.IO
{
List<DirectoryInfo> dirs = new List<DirectoryInfo>();
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(FullName);
System.IO.DirectoryInfo[] arrDi = di.GetDirectories(SearchPattern);
@@ -183,7 +183,7 @@ namespace ROMVault2.IO
{
List<FileInfo> files = new List<FileInfo>();
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(FullName);
System.IO.FileInfo[] arrDi = di.GetFiles(SearchPattern);
@@ -239,7 +239,7 @@ namespace ROMVault2.IO
{
public static bool Exists(string path)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
return System.IO.Directory.Exists(path);
@@ -252,7 +252,7 @@ namespace ROMVault2.IO
}
public static void Move(String sourceDirName, String destDirName)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.Directory.Move(sourceDirName, destDirName);
return;
@@ -288,7 +288,7 @@ namespace ROMVault2.IO
}
public static void Delete(String path)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.Directory.Delete(path);
return;
@@ -301,7 +301,7 @@ namespace ROMVault2.IO
public static void CreateDirectory(String path)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.Directory.CreateDirectory(path);
return;
@@ -323,7 +323,7 @@ namespace ROMVault2.IO
{
public static bool Exists(string path)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
return System.IO.File.Exists(path);
@@ -340,7 +340,7 @@ namespace ROMVault2.IO
}
public static void Copy(String sourceFileName, String destFileName, bool overwrite)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.File.Copy(sourceFileName, destFileName, overwrite);
return;
@@ -387,7 +387,7 @@ namespace ROMVault2.IO
}
public static void Move(String sourceFileName, String destFileName)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.File.Move(sourceFileName, destFileName);
return;
@@ -412,7 +412,7 @@ namespace ROMVault2.IO
}
public static void Delete(String path)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
System.IO.File.Delete(path);
return;
@@ -431,7 +431,7 @@ namespace ROMVault2.IO
public static bool SetAttributes(String path, FileAttributes fileAttributes)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
try
{
@@ -466,7 +466,7 @@ namespace ROMVault2.IO
}
public static string Combine(string path1, string path2)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
return System.IO.Path.Combine(path1, path2);
if (path1 == null || path2 == null)
@@ -538,7 +538,7 @@ namespace ROMVault2.IO
}
public static String GetDirectoryName(String path)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
return System.IO.Path.GetDirectoryName(path);
@@ -600,7 +600,7 @@ namespace ROMVault2.IO
public static int OpenFileRead(string path, out System.IO.Stream stream)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
try
{
@@ -634,7 +634,7 @@ namespace ROMVault2.IO
public static int OpenFileWrite(string path, out System.IO.Stream stream)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
{
try
{
@@ -675,7 +675,7 @@ namespace ROMVault2.IO
{
public static string GetShortPath(string path)
{
if (Settings.MonoFileIO)
if (Settings.IsUnix)
return path;
int remove = 0;

View File

@@ -48,7 +48,7 @@ namespace ROMVault2
public static bool CacheSaveTimerEnabled = true;
public static int CacheSaveTimePeriod = 10;
public static bool MonoFileIO
public static bool IsUnix
{
get
{
@@ -57,6 +57,8 @@ namespace ROMVault2
}
}
public static bool IsMono { get { return (Type.GetType ("Mono.Runtime") != null); } }
public static string EMail
{
get

View File

@@ -246,7 +246,7 @@ namespace ROMVault2.SupportedFiles.CHD
_resultType = CHDManCheck.Unset;
string chdExe = "chdman.exe";
if (Settings.MonoFileIO)
if (Settings.IsUnix)
chdExe = "chdman";
string chdPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, chdExe);