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