Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/BloomExe/web/controllers/CommonApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using Bloom.Api;
Expand Down Expand Up @@ -118,6 +119,13 @@ public void RegisterWithApiHandler(BloomApiHandler apiHandler)
{
result = PortableClipboard.GetText();
}
catch (ExternalException e)
{
// The clipboard was momentarily locked by some other program (BL-16459).
// This is transient and not Bloom's fault, so we don't want a scary
// problem-report dialog; just a gentle toast.
ReportClipboardBusy(e);
}
catch (Exception e)
{
// Need to make sure to handle exceptions.
Expand Down Expand Up @@ -149,6 +157,13 @@ public void RegisterWithApiHandler(BloomApiHandler apiHandler)
{
PortableClipboard.SetText(content);
}
catch (ExternalException e)
{
// The clipboard was momentarily locked by some other program (BL-16459).
// This is transient and not Bloom's fault, so we don't want a scary
// problem-report dialog; just a gentle toast.
ReportClipboardBusy(e);
}
catch (Exception e)
{
// Need to make sure to handle exceptions.
Expand Down Expand Up @@ -269,6 +284,27 @@ private void HandleInstanceInfo(ApiRequest request)
);
}

/// <summary>
/// Sometimes a clipboard copy/paste fails because another program is momentarily holding
/// the Windows clipboard (BL-16459). Windows reports this as an ExternalException. It is
/// transient and not caused by Bloom, so rather than alarm the user with a problem-report
/// dialog we just show a gentle toast (and still log/send to Sentry so we can track it).
/// </summary>
private static void ReportClipboardBusy(ExternalException e)
{
NonFatalProblem.Report(
ModalIf.None,
PassiveIf.All,
LocalizationManager.GetDynamicString(
"Bloom",
"EditTab.Image.CopyImageFailed",
"Bloom had problems using your computer's clipboard. Some other program may be interfering."
),
exception: e,
showSendReport: false
);
}

/// <summary>
/// Whether any modifications to the current book may currently be saved.
/// This is used by many things that don't otherwise need to know about Team Collections,
Expand Down