Skip to content

Commit

Permalink
Ensure C# UI uses consistent culture on all threads. Closes #72
Browse files Browse the repository at this point in the history
* This means that e.g. decimal separator will always be . and similar
  effects, which avoids the need to have culture specific formatting or
  special-case handling around CSV export etc.
  • Loading branch information
baldurk committed Jul 23, 2014
1 parent e94726c commit 74a0330
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 12 deletions.
2 changes: 2 additions & 0 deletions renderdocui/Code/AppMain.cs
Expand Up @@ -105,6 +105,8 @@ static void Main(string[] args)
// propogate float formatting settings to the Formatter class used globally to format float values
cfg.SetupFormatter();

Application.CurrentCulture = new System.Globalization.CultureInfo("en-GB");

var core = new Core(filename, temp, cfg);

try
Expand Down
4 changes: 2 additions & 2 deletions renderdocui/Code/Core.cs
Expand Up @@ -383,7 +383,7 @@ public void LoadLogfile(int proxyRenderer, string replayHost, string logFile, bo
// We'll close it down when log loading finishes (whether it succeeds or fails)
ModalPopup modal = new ModalPopup(LogLoadCallback, true);

Thread modalThread = new Thread(new ThreadStart(() =>
Thread modalThread = Helpers.NewThread(new ThreadStart(() =>
{
modal.SetModalText(string.Format("Loading Log {0}.", m_LogFile));
Expand All @@ -396,7 +396,7 @@ public void LoadLogfile(int proxyRenderer, string replayHost, string logFile, bo

// this thread continually ticks and notifies any threads of the progress, through a float
// that is updated by the main loading code
Thread thread = new Thread(new ThreadStart(() =>
Thread thread = Helpers.NewThread(new ThreadStart(() =>
{
modal.LogfileProgressBegin();
Expand Down
15 changes: 15 additions & 0 deletions renderdocui/Code/Helpers.cs
Expand Up @@ -28,6 +28,7 @@
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using Microsoft.Win32;
Expand Down Expand Up @@ -82,6 +83,20 @@ public static bool IsElevated
}
}

public static Thread NewThread(ParameterizedThreadStart s)
{
Thread ret = new Thread(s);
ret.CurrentCulture = Application.CurrentCulture;
return ret;
}

public static Thread NewThread(ThreadStart s)
{
Thread ret = new Thread(s);
ret.CurrentCulture = Application.CurrentCulture;
return ret;
}

public static void RefreshAssociations()
{
Win32PInvoke.SHChangeNotify(Win32PInvoke.HChangeNotifyEventID.SHCNE_ASSOCCHANGED,
Expand Down
2 changes: 1 addition & 1 deletion renderdocui/Code/RenderManager.cs
Expand Up @@ -89,7 +89,7 @@ public void Init(int proxyRenderer, string replayHost, string logfile)

InitException = null;

m_Thread = new Thread(new ThreadStart(this.RunThread));
m_Thread = Helpers.NewThread(new ThreadStart(this.RunThread));
m_Thread.Priority = ThreadPriority.Highest;
m_Thread.Start();

Expand Down
2 changes: 1 addition & 1 deletion renderdocui/Windows/BufferViewer.cs
Expand Up @@ -1351,7 +1351,7 @@ private void UI_FillRawData(UIState state)
Input input = state.m_Input;
uint instance = m_CurInst;

Thread th = new Thread(new ThreadStart(() =>
Thread th = Helpers.NewThread(new ThreadStart(() =>
{
byte[][] d = data.Buffers;
Expand Down
2 changes: 1 addition & 1 deletion renderdocui/Windows/Dialogs/LiveCapture.cs
Expand Up @@ -115,7 +115,7 @@ public void QueueCapture(int frameNum)

private void LiveCapture_Shown(object sender, EventArgs e)
{
m_ConnectThread = new Thread(new ThreadStart(ConnectionThreadEntry));
m_ConnectThread = Helpers.NewThread(new ThreadStart(ConnectionThreadEntry));
m_ConnectThread.Start();
}

Expand Down
4 changes: 2 additions & 2 deletions renderdocui/Windows/Dialogs/RemoteHostSelect.cs
Expand Up @@ -87,7 +87,7 @@ private void AddHost(String host)

refresh.Enabled = false;

Thread th = new Thread(new ParameterizedThreadStart(LookupHostConnections));
Thread th = Helpers.NewThread(new ParameterizedThreadStart(LookupHostConnections));
th.Start(node);
}

Expand Down Expand Up @@ -263,7 +263,7 @@ private void refresh_Click(object sender, EventArgs e)
n.Image = global::renderdocui.Properties.Resources.hourglass;
n.Bold = false;

Thread th = new Thread(new ParameterizedThreadStart(LookupHostConnections));
Thread th = Helpers.NewThread(new ParameterizedThreadStart(LookupHostConnections));
th.Start(n);
}
hosts.EndUpdate();
Expand Down
8 changes: 4 additions & 4 deletions renderdocui/Windows/MainWindow.cs
Expand Up @@ -561,7 +561,7 @@ private void LoadLogAsync(string filename, bool temporary)
}
}

thread = new Thread(new ThreadStart(() =>
thread = Helpers.NewThread(new ThreadStart(() =>
{
string[] drivers = new string[0];
try
Expand Down Expand Up @@ -644,7 +644,7 @@ private void LoadLogAsync(string filename, bool temporary)
}
else
{
thread = new Thread(new ThreadStart(() => m_Core.LoadLogfile(filename, temporary)));
thread = Helpers.NewThread(new ThreadStart(() => m_Core.LoadLogfile(filename, temporary)));
}

thread.Start();
Expand Down Expand Up @@ -879,7 +879,7 @@ private void CheckUpdates()

m_Core.Config.CheckUpdate_LastUpdate = today;

var updateThread = new Thread(new ThreadStart(() =>
var updateThread = Helpers.NewThread(new ThreadStart(() =>
{
// spawn thread to check update
WebRequest g = HttpWebRequest.Create(String.Format("http://renderdoc.org/checkupdate/{0}", VersionString));
Expand Down Expand Up @@ -1263,7 +1263,7 @@ private void launchReplayHostToolStripMenuItem_Click(object sender, EventArgs e)
{
bool killReplay = false;

Thread thread = new Thread(new ThreadStart(() =>
Thread thread = Helpers.NewThread(new ThreadStart(() =>
{
StaticExports.SpawnReplayHost(ref killReplay);
}));
Expand Down
2 changes: 1 addition & 1 deletion renderdocui/Windows/TextureViewer.cs
Expand Up @@ -2302,7 +2302,7 @@ void rangeHistogram_RangeUpdated(object sender, Controls.RangeHistogramEventArgs
return;
}

rangePaintThread = new Thread(new ThreadStart(() =>
rangePaintThread = Helpers.NewThread(new ThreadStart(() =>
{
m_Core.Renderer.Invoke((ReplayRenderer r) => { RT_UpdateAndDisplay(r); if (m_Output != null) m_Output.Display(); });
Thread.Sleep(8);
Expand Down

0 comments on commit 74a0330

Please sign in to comment.