mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-21 03:54:07 +02:00
Fix more analysis violations (exceptions, native method pointers, form disposal)
This commit is contained in:
@@ -70,7 +70,7 @@ namespace TweetDuck.Core.Controls{
|
|||||||
public static void SetElevated(this Button button){
|
public static void SetElevated(this Button button){
|
||||||
button.Text = " "+button.Text;
|
button.Text = " "+button.Text;
|
||||||
button.FlatStyle = FlatStyle.System;
|
button.FlatStyle = FlatStyle.System;
|
||||||
NativeMethods.SendMessage(button.Handle, NativeMethods.BCM_SETSHIELD, 0, new IntPtr(1));
|
NativeMethods.SendMessage(button.Handle, NativeMethods.BCM_SETSHIELD, new UIntPtr(0), new IntPtr(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableMultilineShortcuts(this TextBox textBox){
|
public static void EnableMultilineShortcuts(this TextBox textBox){
|
||||||
|
@@ -67,10 +67,10 @@ namespace TweetDuck.Core.Utils{
|
|||||||
private static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop);
|
private static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam);
|
public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, UIntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam);
|
public static extern bool PostMessage(IntPtr hWnd, uint msg, UIntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern uint RegisterWindowMessage(string messageName);
|
public static extern uint RegisterWindowMessage(string messageName);
|
||||||
|
@@ -47,9 +47,9 @@ namespace TweetDuck.Plugins{
|
|||||||
|
|
||||||
if (fullPath.Length == 0){
|
if (fullPath.Length == 0){
|
||||||
switch(folder){
|
switch(folder){
|
||||||
case PluginFolder.Data: throw new Exception("File path has to be relative to the plugin data folder.");
|
case PluginFolder.Data: throw new ArgumentException("File path has to be relative to the plugin data folder.");
|
||||||
case PluginFolder.Root: throw new Exception("File path has to be relative to the plugin root folder.");
|
case PluginFolder.Root: throw new ArgumentException("File path has to be relative to the plugin root folder.");
|
||||||
default: throw new Exception("Invalid folder type "+folder+", this is a "+Program.BrandName+" error.");
|
default: throw new ArgumentException("Invalid folder type "+folder+", this is a "+Program.BrandName+" error.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -67,9 +67,9 @@ namespace TweetDuck.Plugins{
|
|||||||
try{
|
try{
|
||||||
return fileCache[token, cacheKey] = File.ReadAllText(fullPath, Encoding.UTF8);
|
return fileCache[token, cacheKey] = File.ReadAllText(fullPath, Encoding.UTF8);
|
||||||
}catch(FileNotFoundException){
|
}catch(FileNotFoundException){
|
||||||
throw new Exception("File not found.");
|
throw new FileNotFoundException("File not found.");
|
||||||
}catch(DirectoryNotFoundException){
|
}catch(DirectoryNotFoundException){
|
||||||
throw new Exception("Directory not found.");
|
throw new DirectoryNotFoundException("Directory not found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -109,7 +109,7 @@ namespace TweetDuck{
|
|||||||
|
|
||||||
if (lockResult == LockManager.Result.HasProcess){
|
if (lockResult == LockManager.Result.HasProcess){
|
||||||
if (LockManager.LockingProcess.MainWindowHandle == IntPtr.Zero){ // restore if the original process is in tray
|
if (LockManager.LockingProcess.MainWindowHandle == IntPtr.Zero){ // restore if the original process is in tray
|
||||||
NativeMethods.PostMessage(NativeMethods.HWND_BROADCAST, WindowRestoreMessage, LockManager.LockingProcess.Id, IntPtr.Zero);
|
NativeMethods.PostMessage(NativeMethods.HWND_BROADCAST, WindowRestoreMessage, new UIntPtr((uint)LockManager.LockingProcess.Id), IntPtr.Zero);
|
||||||
|
|
||||||
if (WindowsUtils.TrySleepUntil(() => {
|
if (WindowsUtils.TrySleepUntil(() => {
|
||||||
LockManager.LockingProcess.Refresh();
|
LockManager.LockingProcess.Refresh();
|
||||||
|
@@ -84,9 +84,10 @@ namespace TweetDuck{
|
|||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
FormMessage form = new FormMessage(caption, message, MessageBoxIcon.Error);
|
using(FormMessage form = new FormMessage(caption, message, MessageBoxIcon.Error)){
|
||||||
form.ActiveControl = form.AddButton("Exit");
|
form.ActiveControl = form.AddButton("Exit");
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
|
Reference in New Issue
Block a user