mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
First code analysis changes, this "should" make Greenshot more stable and implement things as is supposed.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2481 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
3f4d93f2b6
commit
a394904aa3
64 changed files with 514 additions and 343 deletions
|
@ -136,8 +136,14 @@ namespace GreenshotPlugin.Core {
|
|||
public virtual IEnumerable<IDestination> DynamicDestinations() {
|
||||
yield break;
|
||||
}
|
||||
|
||||
public virtual void Dispose() {
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
//if (disposing) {}
|
||||
}
|
||||
|
||||
public virtual bool isDynamic {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
|
||||
|
@ -52,8 +52,14 @@ namespace GreenshotPlugin.Core {
|
|||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dispose() {
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
//if (disposing) {}
|
||||
}
|
||||
|
||||
public virtual bool isActive {
|
||||
|
|
|
@ -43,9 +43,9 @@ namespace GreenshotPlugin.Core {
|
|||
return num;
|
||||
}
|
||||
[DllImport("oleacc.dll")]
|
||||
public static extern int AccessibleObjectFromWindow(IntPtr hwnd, uint id, ref Guid iid, [In, Out, MarshalAs(UnmanagedType.IUnknown)] ref object ppvObject);
|
||||
private static extern int AccessibleObjectFromWindow(IntPtr hwnd, uint id, ref Guid iid, [In, Out, MarshalAs(UnmanagedType.IUnknown)] ref object ppvObject);
|
||||
[DllImport("oleacc.dll")]
|
||||
public static extern int AccessibleChildren(IAccessible paccContainer, int iChildStart, int cChildren, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] object[] rgvarChildren, out int pcObtained);
|
||||
private static extern int AccessibleChildren(IAccessible paccContainer, int iChildStart, int cChildren, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] object[] rgvarChildren, out int pcObtained);
|
||||
|
||||
[DllImport("oleacc.dll", PreserveSig=false)]
|
||||
[return: MarshalAs(UnmanagedType.Interface)]
|
||||
|
|
|
@ -435,7 +435,7 @@ namespace GreenshotPlugin.Core {
|
|||
// adding additional data for bug tracking
|
||||
e.Data.Add("title", captureDetails.Title);
|
||||
e.Data.Add("pattern", pattern);
|
||||
throw e;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -406,22 +406,23 @@ namespace GreenshotPlugin.Core {
|
|||
/// <returns>Path to filename</returns>
|
||||
public static string SaveWithDialog(ISurface surface, ICaptureDetails captureDetails) {
|
||||
string returnValue = null;
|
||||
SaveImageFileDialog saveImageFileDialog = new SaveImageFileDialog(captureDetails);
|
||||
DialogResult dialogResult = saveImageFileDialog.ShowDialog();
|
||||
if (dialogResult.Equals(DialogResult.OK)) {
|
||||
try {
|
||||
string fileNameWithExtension = saveImageFileDialog.FileNameWithExtension;
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(FormatForFilename(fileNameWithExtension));
|
||||
if (conf.OutputFilePromptQuality) {
|
||||
QualityDialog qualityDialog = new QualityDialog(outputSettings);
|
||||
qualityDialog.ShowDialog();
|
||||
using (SaveImageFileDialog saveImageFileDialog = new SaveImageFileDialog(captureDetails)) {
|
||||
DialogResult dialogResult = saveImageFileDialog.ShowDialog();
|
||||
if (dialogResult.Equals(DialogResult.OK)) {
|
||||
try {
|
||||
string fileNameWithExtension = saveImageFileDialog.FileNameWithExtension;
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(FormatForFilename(fileNameWithExtension));
|
||||
if (conf.OutputFilePromptQuality) {
|
||||
QualityDialog qualityDialog = new QualityDialog(outputSettings);
|
||||
qualityDialog.ShowDialog();
|
||||
}
|
||||
// TODO: For now we always overwrite, should be changed
|
||||
ImageOutput.Save(surface, fileNameWithExtension, true, outputSettings, conf.OutputFileCopyPathToClipboard);
|
||||
returnValue = fileNameWithExtension;
|
||||
IniConfig.Save();
|
||||
} catch (System.Runtime.InteropServices.ExternalException) {
|
||||
MessageBox.Show(Language.GetFormattedString("error_nowriteaccess", saveImageFileDialog.FileName).Replace(@"\\", @"\"), Language.GetString("error"));
|
||||
}
|
||||
// TODO: For now we always overwrite, should be changed
|
||||
ImageOutput.Save(surface, fileNameWithExtension, true, outputSettings, conf.OutputFileCopyPathToClipboard);
|
||||
returnValue = fileNameWithExtension;
|
||||
IniConfig.Save();
|
||||
} catch (System.Runtime.InteropServices.ExternalException) {
|
||||
MessageBox.Show(Language.GetFormattedString("error_nowriteaccess", saveImageFileDialog.FileName).Replace(@"\\", @"\"), Language.GetString("error"));
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
|
|
|
@ -28,7 +28,7 @@ using Greenshot.IniFile;
|
|||
using Microsoft.Win32;
|
||||
|
||||
namespace GreenshotPlugin.Core {
|
||||
public delegate void LanguageChangedHandler();
|
||||
public delegate void LanguageChangedHandler(object sender, EventArgs e);
|
||||
/// <summary>
|
||||
/// This class supplies the GUI with translations, based upon keys.
|
||||
/// The language resources are loaded from the language files found on fixed or supplied paths
|
||||
|
@ -202,7 +202,7 @@ namespace GreenshotPlugin.Core {
|
|||
Reload();
|
||||
if (LanguageChanged != null) {
|
||||
try {
|
||||
LanguageChanged();
|
||||
LanguageChanged(null, null);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ namespace GreenshotPlugin.Core {
|
|||
using (Stream responseStream = response.GetResponseStream()) {
|
||||
LOG.ErrorFormat("HTTP error {0} with content: {1}", response.StatusCode, new StreamReader(responseStream, true).ReadToEnd());
|
||||
}
|
||||
throw e;
|
||||
throw;
|
||||
}
|
||||
|
||||
return responseData;
|
||||
|
|
|
@ -405,7 +405,7 @@ namespace GreenshotPlugin.Core {
|
|||
return getAccessToken() != null;
|
||||
} catch (Exception ex) {
|
||||
LOG.Error(ex);
|
||||
throw ex;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,7 +518,7 @@ namespace GreenshotPlugin.Core {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
throw wEx;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
if (lastException != null) {
|
||||
|
|
|
@ -101,9 +101,16 @@ namespace GreenshotPlugin.Core {
|
|||
private Bitmap resultBitmap;
|
||||
|
||||
public void Dispose() {
|
||||
if (resultBitmap != null) {
|
||||
resultBitmap.Dispose();
|
||||
resultBitmap = null;
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
if (resultBitmap != null) {
|
||||
resultBitmap.Dispose();
|
||||
resultBitmap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,6 @@ namespace GreenshotPlugin.Core {
|
|||
private WindowDetails parent = null;
|
||||
private bool frozen = false;
|
||||
|
||||
|
||||
public bool isApp {
|
||||
get {
|
||||
return METRO_WINDOWS_CLASS.Equals(ClassName);
|
||||
|
@ -1105,6 +1104,7 @@ namespace GreenshotPlugin.Core {
|
|||
tempForm.Close();
|
||||
}
|
||||
tempForm.Dispose();
|
||||
tempForm = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue