Skip to content

Commit bac354d

Browse files
committed
Merge branch 'gkuegler-master' into 'master'
Resolves dictation-toolbox#390.
2 parents 5dcd851 + 8358e1f commit bac354d

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

dragonfly/windows/base_clipboard.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ def synchronized_changes(cls, timeout, step=0.001, formats=None,
163163
"""
164164
Context manager for synchronizing local and system clipboard
165165
changes. This takes the same arguments as the
166-
:meth:`wait_for_change` method.
166+
:meth:`wait_for_change` method. A ``RuntimeError`` is raised if
167+
the system clipboard does not change.
167168
168169
Arguments:
169170
- *timeout* (float) -- timeout in seconds.
@@ -197,8 +198,13 @@ def synchronized_changes(cls, timeout, step=0.001, formats=None,
197198
# Yield for clipboard operations.
198199
yield
199200
finally:
200-
# Wait for the system clipboard to change.
201-
cls.wait_for_change(timeout, step, formats, initial_clipboard)
201+
# Wait for the system clipboard to change, raising an error on
202+
# failure.
203+
changed = cls.wait_for_change(timeout, step, formats,
204+
initial_clipboard)
205+
if not changed:
206+
message = "Timed out waiting for clipboard to change"
207+
raise RuntimeError(message)
202208

203209
#-----------------------------------------------------------------------
204210

dragonfly/windows/win32_clipboard.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,13 @@ def synchronized_changes(cls, timeout, step=0.001, formats=None,
225225
# Yield for clipboard operations.
226226
yield
227227
finally:
228-
# Wait for the system clipboard to change.
229-
cls._wait_for_change(timeout, step, formats, initial_clipboard,
230-
seq_no)
228+
# Wait for the system clipboard to change, raising an error on
229+
# failure.
230+
changed = cls._wait_for_change(timeout, step, formats,
231+
initial_clipboard, seq_no)
232+
if not changed:
233+
message = "Timed out waiting for clipboard to change"
234+
raise RuntimeError(message)
231235

232236
#-----------------------------------------------------------------------
233237

0 commit comments

Comments
 (0)