Skip to content

Don't raise exception when close method of an already-closed dock is called#2089

Merged
j9ac9k merged 2 commits intopyqtgraph:masterfrom
max-radin:closing-closed-dock
Nov 14, 2021
Merged

Don't raise exception when close method of an already-closed dock is called#2089
j9ac9k merged 2 commits intopyqtgraph:masterfrom
max-radin:closing-closed-dock

Conversation

@max-radin
Copy link
Copy Markdown
Contributor

See #1702

def close(self):
"""Remove this dock from the DockArea it lives inside."""
if self._container is None:
warnings.warn(f"Cannot close dock {self} because it is not open.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice touch on the warning! I think you need to add stacklevel=2 to capture the correct context

warnings.warn(f"Cannot close dock {self} because it is not open.", RuntimeWarning, stacklevel=2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point! fixed in 53fe2b3

@j9ac9k j9ac9k linked an issue Nov 14, 2021 that may be closed by this pull request
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Nov 14, 2021

Thanks @max-radin merging!

@j9ac9k j9ac9k merged commit 0a7ce47 into pyqtgraph:master Nov 14, 2021
ntjess pushed a commit to ntjess/pyqtgraph that referenced this pull request Dec 10, 2021
…called (pyqtgraph#2089)

* Don't raise exception if user tries to close a dock that's not open

* Adding stacklevel to warning on dock close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'NoneType' object has no attribute 'apoptose'

2 participants