Repository navigation
Detect headless GIMP instead of hiding display errors - #183
Conversation
_create_display() caught every Gimp.Display.new() exception so headless runs (gimp -i) wouldn't fail open_image/new_canvas, which also hid real display failures in GUI mode. Check Gimp.Display.name() instead: it is None when GIMP has no GUI, so no window is attempted there. In GUI mode a Display.new() failure now comes back as a "warning" next to display_opened: false; the image is still created, so the call doesn't fail.
|
No actionable comments were generated in the recent review. WalkthroughThe plugin now skips display creation when GIMP has no display. When display creation fails in GUI mode, ChangesDisplay reporting
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Possibly related PRs
Suggested labels: Suggested reviewers: Merge Risk:
|
Fixes #88.
_create_display()caught everyGimp.Display.new()exception, so headless runs (gimp -i) wouldn't failopen_image/new_canvas. That also hid real display failures in GUI mode: the call returned success withdisplay_opened: false, and the cause appeared only in GIMP's stdout.Change
Gimp.Display.name()is documented to return NULL when GIMP runs without a GUI (--no-interfaceor a console build). When it isNone,_create_display()doesn't try to open a window, and the result isdisplay_opened: falsewith no warning, as before.Display.new()failure now reaches the caller. The new_display_result()turns it into awarningnext todisplay_opened: false. The call still succeeds, because the image already exists: an error would leave it open without the caller knowing its id.new_canvasandopen_imageuse_display_result(). The server docstrings documentwarning, andCHANGELOG.mdhas a Fixed entry.Testing
tests/test_open_image_headless.pynow covers three cases: headless (Display.newmust not be called), GUI success, and GUI failure (warning names the error). It fails on the old code for the headless and GUI-failure cases.tests/test_gimp3_compat.py: theDisplaystub gainsname().ruff checkpass.gimp -i:Display.name()isNone, andDisplay.new()raisesTypeError: constructor returned NULL.Display.name()is':0', andnew_canvasreturnsdisplay_opened: true. WithDisplay.newpatched to raise inside GIMP,new_canvasreturneddisplay_opened: falseplus the warning, and the image existed.Summary by CodeRabbit