mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 09:33:46 -07:00
Counting the amount of surface objects, so we can see if there are multiple in memory when we have bugs.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2365 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
1a471ec77f
commit
83d244c3bf
5 changed files with 116 additions and 140 deletions
|
@ -45,6 +45,7 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
public class Surface : Control, ISurface {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(Surface));
|
||||
public static int Count = 0;
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
|
||||
/// <summary>
|
||||
|
@ -360,7 +361,8 @@ namespace Greenshot.Drawing {
|
|||
/// Base Surface constructor
|
||||
/// </summary>
|
||||
public Surface() : base(){
|
||||
LOG.Debug("Creating a surface!");
|
||||
Count++;
|
||||
LOG.Debug("Creating surface!");
|
||||
this.MouseDown += new MouseEventHandler(SurfaceMouseDown);
|
||||
this.MouseUp += new MouseEventHandler(SurfaceMouseUp);
|
||||
this.MouseMove += new MouseEventHandler(SurfaceMouseMove);
|
||||
|
@ -427,7 +429,8 @@ namespace Greenshot.Drawing {
|
|||
/// Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
|
||||
/// </summary>
|
||||
public new void Dispose() {
|
||||
LOG.Debug("Disposing a surface!");
|
||||
Count--;
|
||||
LOG.Debug("Disposing surface!");
|
||||
if (buffer != null) {
|
||||
buffer.Dispose();
|
||||
buffer = null;
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace Greenshot {
|
|||
/// Description of AboutForm.
|
||||
/// </summary>
|
||||
public partial class AboutForm : BaseForm {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AboutForm));
|
||||
public AboutForm() {
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
|
@ -88,7 +89,8 @@ namespace Greenshot {
|
|||
default:
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
} catch (Exception) {
|
||||
} catch (Exception ex) {
|
||||
LOG.Error(string.Format("Error handling key '{0}'", keyData), ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -67,11 +67,15 @@ namespace Greenshot {
|
|||
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
|
||||
// Initialize the IniConfig
|
||||
IniConfig.Init();
|
||||
|
||||
// Log the startup
|
||||
LOG.Info("Starting: " + EnvironmentInfo.EnvironmentToString(false));
|
||||
|
||||
IniConfig.Init();
|
||||
// Upgrade if needed
|
||||
AppConfig.UpgradeToIni();
|
||||
|
||||
// Read configuration
|
||||
conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
try {
|
||||
|
|
|
@ -28,6 +28,7 @@ using System.Windows.Forms;
|
|||
using GreenshotPlugin.UnmanagedHelpers;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Drawing;
|
||||
|
||||
namespace Greenshot.Helpers {
|
||||
/// <summary>
|
||||
|
@ -67,13 +68,13 @@ namespace Greenshot.Helpers {
|
|||
environment.Append(", ");
|
||||
}
|
||||
environment.Append("Time: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss zzz"));
|
||||
|
||||
if (IsWindows) {
|
||||
if (newline) {
|
||||
environment.AppendLine();
|
||||
} else {
|
||||
environment.Append(", ");
|
||||
}
|
||||
|
||||
if (IsWindows) {
|
||||
environment.Append(String.Format("OS: {0} {1} {2} (x{3}) {4}", OSInfo.Name, OSInfo.Edition, OSInfo.ServicePack, OSInfo.Bits, OSInfo.VersionString));
|
||||
if (newline) {
|
||||
environment.AppendLine();
|
||||
|
@ -89,13 +90,19 @@ namespace Greenshot.Helpers {
|
|||
}
|
||||
environment.Append("User object count: " + User32.GetGuiResourcesUserCount());
|
||||
} else {
|
||||
environment.Append("OS: " + Environment.OSVersion.Platform.ToString());
|
||||
if (newline) {
|
||||
environment.AppendLine();
|
||||
} else {
|
||||
environment.Append(", ");
|
||||
}
|
||||
environment.Append("OS: " + Environment.OSVersion.Platform.ToString());
|
||||
}
|
||||
if (newline) {
|
||||
environment.AppendLine();
|
||||
} else {
|
||||
environment.Append(", ");
|
||||
}
|
||||
environment.Append("Surface count: " + Surface.Count);
|
||||
|
||||
return environment.ToString();
|
||||
}
|
||||
|
@ -162,8 +169,7 @@ namespace Greenshot.Helpers {
|
|||
/// Determines if the current application is 32 or 64-bit.
|
||||
/// </summary>
|
||||
static public int Bits {
|
||||
get
|
||||
{
|
||||
get {
|
||||
return IntPtr.Size * 8;
|
||||
}
|
||||
}
|
||||
|
@ -193,22 +199,15 @@ namespace Greenshot.Helpers {
|
|||
short suiteMask = osVersionInfo.wSuiteMask;
|
||||
|
||||
#region VERSION 4
|
||||
if (majorVersion == 4)
|
||||
{
|
||||
if (productType == VER_NT_WORKSTATION)
|
||||
{
|
||||
if (majorVersion == 4) {
|
||||
if (productType == VER_NT_WORKSTATION) {
|
||||
// Windows NT 4.0 Workstation
|
||||
edition = "Workstation";
|
||||
}
|
||||
else if (productType == VER_NT_SERVER)
|
||||
{
|
||||
if ((suiteMask & VER_SUITE_ENTERPRISE) != 0)
|
||||
{
|
||||
} else if (productType == VER_NT_SERVER) {
|
||||
if ((suiteMask & VER_SUITE_ENTERPRISE) != 0) {
|
||||
// Windows NT 4.0 Server Enterprise
|
||||
edition = "Enterprise Server";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Windows NT 4.0 Server
|
||||
edition = "Standard Server";
|
||||
}
|
||||
|
@ -217,60 +216,38 @@ namespace Greenshot.Helpers {
|
|||
#endregion VERSION 4
|
||||
|
||||
#region VERSION 5
|
||||
else if (majorVersion == 5)
|
||||
{
|
||||
if (productType == VER_NT_WORKSTATION)
|
||||
{
|
||||
if ((suiteMask & VER_SUITE_PERSONAL) != 0)
|
||||
{
|
||||
else if (majorVersion == 5) {
|
||||
if (productType == VER_NT_WORKSTATION) {
|
||||
if ((suiteMask & VER_SUITE_PERSONAL) != 0) {
|
||||
// Windows XP Home Edition
|
||||
edition = "Home";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Windows XP / Windows 2000 Professional
|
||||
edition = "Professional";
|
||||
}
|
||||
}
|
||||
else if (productType == VER_NT_SERVER)
|
||||
{
|
||||
if (minorVersion == 0)
|
||||
{
|
||||
if ((suiteMask & VER_SUITE_DATACENTER) != 0)
|
||||
{
|
||||
} else if (productType == VER_NT_SERVER) {
|
||||
if (minorVersion == 0) {
|
||||
if ((suiteMask & VER_SUITE_DATACENTER) != 0) {
|
||||
// Windows 2000 Datacenter Server
|
||||
edition = "Datacenter Server";
|
||||
}
|
||||
else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0)
|
||||
{
|
||||
} else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0) {
|
||||
// Windows 2000 Advanced Server
|
||||
edition = "Advanced Server";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Windows 2000 Server
|
||||
edition = "Server";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((suiteMask & VER_SUITE_DATACENTER) != 0)
|
||||
{
|
||||
} else {
|
||||
if ((suiteMask & VER_SUITE_DATACENTER) != 0) {
|
||||
// Windows Server 2003 Datacenter Edition
|
||||
edition = "Datacenter";
|
||||
}
|
||||
else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0)
|
||||
{
|
||||
} else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0) {
|
||||
// Windows Server 2003 Enterprise Edition
|
||||
edition = "Enterprise";
|
||||
}
|
||||
else if ((suiteMask & VER_SUITE_BLADE) != 0)
|
||||
{
|
||||
} else if ((suiteMask & VER_SUITE_BLADE) != 0) {
|
||||
// Windows Server 2003 Web Edition
|
||||
edition = "Web Edition";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Windows Server 2003 Standard Edition
|
||||
edition = "Standard";
|
||||
}
|
||||
|
@ -280,13 +257,10 @@ namespace Greenshot.Helpers {
|
|||
#endregion VERSION 5
|
||||
|
||||
#region VERSION 6
|
||||
else if (majorVersion == 6)
|
||||
{
|
||||
else if (majorVersion == 6) {
|
||||
int ed;
|
||||
if (GetProductInfo( majorVersion, minorVersion, osVersionInfo.wServicePackMajor, osVersionInfo.wServicePackMinor, out ed ))
|
||||
{
|
||||
switch (ed)
|
||||
{
|
||||
if (GetProductInfo(majorVersion, minorVersion, osVersionInfo.wServicePackMajor, osVersionInfo.wServicePackMinor, out ed)) {
|
||||
switch (ed) {
|
||||
case PRODUCT_BUSINESS:
|
||||
edition = "Business";
|
||||
break;
|
||||
|
@ -569,8 +543,7 @@ namespace Greenshot.Helpers {
|
|||
|
||||
#region OSVERSIONINFOEX
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct OSVERSIONINFOEX
|
||||
{
|
||||
private struct OSVERSIONINFOEX {
|
||||
public int dwOSVersionInfoSize;
|
||||
public int dwMajorVersion;
|
||||
public int dwMinorVersion;
|
||||
|
@ -646,17 +619,14 @@ namespace Greenshot.Helpers {
|
|||
/// <summary>
|
||||
/// Gets the service pack information of the operating system running on this computer.
|
||||
/// </summary>
|
||||
static public string ServicePack
|
||||
{
|
||||
get
|
||||
{
|
||||
static public string ServicePack {
|
||||
get {
|
||||
string servicePack = String.Empty;
|
||||
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
|
||||
|
||||
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
|
||||
|
||||
if (GetVersionEx( ref osVersionInfo ))
|
||||
{
|
||||
if (GetVersionEx(ref osVersionInfo)) {
|
||||
servicePack = osVersionInfo.szCSDVersion;
|
||||
}
|
||||
|
||||
|
@ -693,10 +663,8 @@ namespace Greenshot.Helpers {
|
|||
/// <summary>
|
||||
/// Gets the full version of the operating system running on this computer.
|
||||
/// </summary>
|
||||
static public Version Version
|
||||
{
|
||||
get
|
||||
{
|
||||
static public Version Version {
|
||||
get {
|
||||
return Environment.OSVersion.Version;
|
||||
}
|
||||
}
|
||||
|
@ -707,10 +675,8 @@ namespace Greenshot.Helpers {
|
|||
/// <summary>
|
||||
/// Gets the major version number of the operating system running on this computer.
|
||||
/// </summary>
|
||||
static public int MajorVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
static public int MajorVersion {
|
||||
get {
|
||||
return Environment.OSVersion.Version.Major;
|
||||
}
|
||||
}
|
||||
|
@ -720,10 +686,8 @@ namespace Greenshot.Helpers {
|
|||
/// <summary>
|
||||
/// Gets the minor version number of the operating system running on this computer.
|
||||
/// </summary>
|
||||
static public int MinorVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
static public int MinorVersion {
|
||||
get {
|
||||
return Environment.OSVersion.Version.Minor;
|
||||
}
|
||||
}
|
||||
|
@ -733,10 +697,8 @@ namespace Greenshot.Helpers {
|
|||
/// <summary>
|
||||
/// Gets the revision version number of the operating system running on this computer.
|
||||
/// </summary>
|
||||
static public int RevisionVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
static public int RevisionVersion {
|
||||
get {
|
||||
return Environment.OSVersion.Version.Revision;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,7 +305,12 @@ namespace Greenshot.IniFile {
|
|||
Value = defaultValueFromConfig;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Value = Activator.CreateInstance(ValueType);
|
||||
} catch (Exception) {
|
||||
LOG.WarnFormat("Couldn't create instance of {0} for {1}, using default value.", ValueType.FullName, attributes.Name);
|
||||
Value = default(ValueType);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue