Fixed bug #3582282 with displaying a dialog so the user can retry the operation after closing the dialog of the target application.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2233 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-11-04 16:24:12 +00:00
commit cd01b2197b
4 changed files with 53 additions and 34 deletions

View file

@ -35,6 +35,8 @@ schnell zu finden. Vielen Dank :)</resource>
<resource name="colorpicker_red">Rot</resource> <resource name="colorpicker_red">Rot</resource>
<resource name="colorpicker_title">Farbauswahl</resource> <resource name="colorpicker_title">Farbauswahl</resource>
<resource name="colorpicker_transparent">Transparent</resource> <resource name="colorpicker_transparent">Transparent</resource>
<resource name="com_rejected">Das Ziel hat Greenshot abgewiesen, vermutlich ist ein Dialogfeld geöffnet. Schließen Sie das Dialogfeld und versuchen Sie es erneut.</resource>
<resource name="com_rejected_title">Greenshot Zugriff abgewiesen</resource>
<resource name="config_unauthorizedaccess_write">Die Greenshot Einstellungen konnten nicht gespeichert werden. Bitte prüfen Sie die Berechtigungen auf '{0}'.</resource> <resource name="config_unauthorizedaccess_write">Die Greenshot Einstellungen konnten nicht gespeichert werden. Bitte prüfen Sie die Berechtigungen auf '{0}'.</resource>
<resource name="contextmenu_about">Über Greenshot</resource> <resource name="contextmenu_about">Über Greenshot</resource>
<resource name="contextmenu_capturearea">Bereich abfotografieren</resource> <resource name="contextmenu_capturearea">Bereich abfotografieren</resource>

View file

@ -35,6 +35,8 @@ Also, we would highly appreciate if you checked whether a tracker item already e
<resource name="colorpicker_red">Red</resource> <resource name="colorpicker_red">Red</resource>
<resource name="colorpicker_title">Color picker</resource> <resource name="colorpicker_title">Color picker</resource>
<resource name="colorpicker_transparent">Transparent</resource> <resource name="colorpicker_transparent">Transparent</resource>
<resource name="com_rejected">The destination rejected Greenshot access, a dialog is probably open. Close the dialog and try again.</resource>
<resource name="com_rejected_title">Greenshot access rejected</resource>
<resource name="config_unauthorizedaccess_write">Could not save Greenshot's configuration file. Please check access permissions for '{0}'.</resource> <resource name="config_unauthorizedaccess_write">Could not save Greenshot's configuration file. Please check access permissions for '{0}'.</resource>
<resource name="contextmenu_about">About Greenshot</resource> <resource name="contextmenu_about">About Greenshot</resource>
<resource name="contextmenu_capturearea">Capture region</resource> <resource name="contextmenu_capturearea">Capture region</resource>

View file

@ -24,6 +24,8 @@ using System.Runtime.InteropServices;
using System.Runtime.Remoting; using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging; using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies; using System.Runtime.Remoting.Proxies;
using System.Windows.Forms;
using GreenshotPlugin.Core;
namespace Greenshot.Interop { namespace Greenshot.Interop {
/// <summary> /// <summary>
@ -33,6 +35,7 @@ namespace Greenshot.Interop {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(COMWrapper)); private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(COMWrapper));
private const int MK_E_UNAVAILABLE = -2147221021; private const int MK_E_UNAVAILABLE = -2147221021;
private const int CO_E_CLASSSTRING = -2147221005; private const int CO_E_CLASSSTRING = -2147221005;
private const int RPC_E_CALL_REJECTED = unchecked((int)0x80010001);
#region Private Data #region Private Data
@ -556,11 +559,23 @@ namespace Greenshot.Interop {
} }
} }
do {
try { try {
returnValue = invokeType.InvokeMember(methodName, flags, null, invokeObject, args, argModifiers, null, null); returnValue = invokeType.InvokeMember(methodName, flags, null, invokeObject, args, argModifiers, null, null);
break;
} catch (Exception ex) { } catch (Exception ex) {
// Test for rejected
COMException comEx = ex as COMException;
if (comEx != null && comEx.ErrorCode == RPC_E_CALL_REJECTED) {
DialogResult result = MessageBox.Show(Language.GetString("com_rejected"), Language.GetString("com_rejected_title"), MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (result == DialogResult.OK) {
continue;
}
}
// Not rejected OR pressed cancel
return new ReturnMessage(ex, callMessage); return new ReturnMessage(ex, callMessage);
} }
} while (true);
// Handle enum and interface return types // Handle enum and interface return types
if (null != returnValue) { if (null != returnValue) {

View file

@ -364,9 +364,9 @@ namespace Greenshot.Interop.Office {
newMail.Display(false); newMail.Display(false);
newMail.GetInspector().Activate(); newMail.GetInspector().Activate();
} catch (Exception ex) { } catch (Exception ex) {
LOG.WarnFormat("Problem displaying the new email, retrying to display it. Problem: {0}", ex.Message); LOG.Warn("Problem displaying the new email, retrying to display it. Problem:", ex);
Thread retryDisplayEmail = new Thread(delegate() { Thread retryDisplayEmail = new Thread(delegate() {
int retries = 60; int retries = 10;
int retryInXSeconds = 5; int retryInXSeconds = 5;
while (retries-- > 0) { while (retries-- > 0) {
Thread.Sleep(retryInXSeconds * 1000); Thread.Sleep(retryInXSeconds * 1000);