Skip to content

Commit 3fd308a

Browse files
committed
Merge pull request matplotlib#583 from dhyams/wx-check-clipboard
Check before opening clipboard in wx
2 parents 5e9aa4f + 7011647 commit 3fd308a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,13 @@ def Copy_to_Clipboard(self, event=None):
777777
"copy bitmap of canvas to system clipboard"
778778
bmp_obj = wx.BitmapDataObject()
779779
bmp_obj.SetBitmap(self.bitmap)
780-
wx.TheClipboard.Open()
781-
wx.TheClipboard.SetData(bmp_obj)
782-
wx.TheClipboard.Close()
783-
wx.TheClipboard.Flush()
780+
781+
if not wx.TheClipboard.IsOpened():
782+
open_success = wx.TheClipboard.Open()
783+
if open_success:
784+
wx.TheClipboard.SetData(bmp_obj)
785+
wx.TheClipboard.Close()
786+
wx.TheClipboard.Flush()
784787

785788
def Printer_Init(self):
786789
"""

0 commit comments

Comments
 (0)