Skip to content

Commit 25e8572

Browse files
committed
init_mgl_context fails when no callback is provided
1 parent 5944113 commit 25e8572

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 3.0.2
4+
5+
* Fixed an issue causing `BaseWindow.init_mgl_context` to fail if no context
6+
creation callback was provided.
7+
38
## 3.0.1
49

510
* Timers now have `fps` and `fps_average` properties for obtaining the current and average frame rate

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __getattr__(cls: Any, name: Any) -> MagicMock:
6060
author = "Einar Forselv"
6161

6262
# The short X.Y version
63-
version = "3.0.1"
63+
version = "3.0.2"
6464
# The full version, including alpha/beta/rc tags
6565
release = version
6666

moderngl_window/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from moderngl_window.utils.keymaps import AZERTY, QWERTY, KeyMap, KeyMapFactory # noqa
2020
from moderngl_window.utils.module_loading import import_string
2121

22-
__version__ = "3.0.1"
22+
__version__ = "3.0.2"
2323

2424
IGNORE_DIRS = [
2525
"__pycache__",

moderngl_window/context/base/window.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __init__(
9292
samples: int = 0,
9393
cursor: bool = True,
9494
backend: Optional[str] = None,
95-
context_creation_func: Optional[Callable] = None,
95+
context_creation_func: Optional[Callable[[], Optional[moderngl.Context]]] = None,
9696
**kwargs: Any,
9797
) -> None:
9898
"""Initialize a window instance.
@@ -190,10 +190,13 @@ def init_mgl_context(self) -> None:
190190
Keyword Args:
191191
ctx: An optional custom ModernGL context
192192
"""
193+
ctx: Optional[moderngl.Context] = None
193194
if self._context_creation_func:
194-
self._ctx = self._context_creation_func()
195-
if self._ctx is None:
196-
self._ctx = moderngl.create_context(require=self.gl_version_code)
195+
ctx = self._context_creation_func()
196+
if ctx is None:
197+
ctx = moderngl.create_context(require=self.gl_version_code)
198+
self._ctx = ctx
199+
197200
err = self._ctx.error
198201
if err != "GL_NO_ERROR":
199202
logger.info("Consumed the following error during context creation: %s", err)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "moderngl-window"
3-
version = "3.0.1"
3+
version = "3.0.2"
44
description = "A cross platform helper library for ModernGL making window creation and resource loading simple"
55
readme = "README.md"
66
authors = [{ name = "Einar Forselv", email = "[email protected]" }]

0 commit comments

Comments
 (0)