Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix a bug with setting the active tabwidget when an editor contains t…
…abs. If an editor contains tabs, after certain operations (e.g., navigating the editor tabs using keyboard shortcuts) a change in focus sets the editor area pane `active_tabwidget` to one of those internal tabs, rather than to the tab of the editor in the editor area.
- Loading branch information
Pietro Berkes
committed
Jun 20, 2013
1 parent
1719195
commit da80101
Showing
3 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright (c) 2013 by Enthought, Inc., Austin, TX | ||
# All rights reserved. | ||
# This file is confidential and NOT open source. Do not distribute. | ||
""" Tools for testing. """ | ||
|
||
|
||
from contextlib import contextmanager | ||
|
||
from pyface.qt.QtCore import QTimer | ||
from pyface.util.guisupport import get_app_qt4 | ||
|
||
|
||
@contextmanager | ||
def event_loop(): | ||
""" Post and process the Qt events at the exit of the code block. """ | ||
|
||
app = get_app_qt4() | ||
|
||
yield | ||
|
||
app.sendPostedEvents() | ||
app.processEvents() | ||
|
||
|
||
@contextmanager | ||
def delete_widget(widget, timeout=1.0): | ||
""" Context manager that executes the event loop so that we can safely | ||
delete a Qt widget. | ||
""" | ||
|
||
app = get_app_qt4() | ||
|
||
timer = QTimer() | ||
timer.setSingleShot(True) | ||
timer.setInterval(timeout*1000) | ||
timer.timeout.connect(app.quit) | ||
widget.destroyed.connect(app.quit) | ||
|
||
yield | ||
|
||
timer.start() | ||
app.exec_() | ||
|
||
if not timer.isActive(): | ||
# We exited the event loop on timeout. | ||
msg = 'Could not destroy widget before timeout: {!r}' | ||
raise AssertionError(msg.format(widget)) |