v0.87.1: one app icon (lint.jpg, wave's corner radius) on desktop and andTunes 0.4.2; quitting no longer segfaults

The swap-a-PNG icon is gone: scripts/make_icons.py renders packaging/lint.jpg
into packaging/lintunes.png and the andTunes launcher. Quitting ends with
os._exit once aboutToQuit has saved everything — Python's teardown of the
QApplication wrapper segfaulted on every quit.
This commit is contained in:
2026-11-06 02:01:06 -08:00
parent 39bbfaa5c0
commit d93a265c33
14 changed files with 132 additions and 28 deletions
+9
View File
@@ -1328,6 +1328,15 @@ persistence) → GUI (Qt widgets that read the manager and connect to its signal
When a feature needs a shape the fixture lacks, **add it to the generator** When a feature needs a shape the fixture lacks, **add it to the generator**
rather than reaching for the real library. rather than reaching for the real library.
- **One app icon** (Round 121): `packaging/lint.jpg`, corners rounded at
wave's radius (16 % of the side), rendered by `scripts/make_icons.py` into
`packaging/lintunes.png` (desktop, 512 px, installed by
`packaging/install-desktop.sh`) and andTunes' `ic_launcher.png` — the same
icon on both. There is no swap-a-PNG customization any more; after
remaking it, `andtunes/build.py --ship`.
- **Quitting ends with `main.leave`** (`os._exit` after `aboutToQuit` has
saved everything): a normal `sys.exit` let Python free the QApplication's
wrapper in random order and sip segfaulted on every quit.
- `scripts/` holds one-off maintenance tools (`audit_artwork.py`, - `scripts/` holds one-off maintenance tools (`audit_artwork.py`,
`recover_artwork.py`, `clear_computed_ratings.py`) run manually against a data `recover_artwork.py`, `clear_computed_ratings.py`) run manually against a data
dir; most default to dry-run and need `--write` to mutate files. dir; most default to dry-run and need `--write` to mutate files.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 60 KiB

+2 -2
View File
@@ -26,8 +26,8 @@ import sys
import zipfile import zipfile
from pathlib import Path from pathlib import Path
VERSION_NAME = "0.4.1" VERSION_NAME = "0.4.2"
VERSION_CODE = 8 VERSION_CODE = 9
PACKAGE = "me.teafry.andtunes" PACKAGE = "me.teafry.andtunes"
MIN_SDK = 26 MIN_SDK = 26
+1 -16
View File
@@ -171,21 +171,6 @@ def toggle_icon(name: str, color="black", size=ICON) -> QImage:
return image return image
def launcher() -> QImage:
size = 192
image, p = _canvas(size, size)
path = QPainterPath()
path.addRoundedRect(QRectF(8, 8, size - 16, size - 16), 36, 36)
p.fillPath(path, QColor("black"))
p.setPen(Qt.PenStyle.NoPen)
p.setBrush(QColor("white"))
p.drawPolygon(_tri(70, 50, 142, 96))
p.drawPolygon(QPolygonF([QPointF(70, 96), QPointF(142, 96),
QPointF(70, 142)]))
p.end()
return image
def save(image: QImage, name: str, *dirs: Path): def save(image: QImage, name: str, *dirs: Path):
for d in dirs: for d in dirs:
d.mkdir(parents=True, exist_ok=True) d.mkdir(parents=True, exist_ok=True)
@@ -201,7 +186,7 @@ def main():
save(transport(name), name, RES, SHIP) save(transport(name), name, RES, SHIP)
for name in TOGGLES: for name in TOGGLES:
save(toggle_icon(name), name, RES, SHIP) save(toggle_icon(name), name, RES, SHIP)
save(launcher(), "ic_launcher", RES) # The launcher icon is LinTunes' own: scripts/make_icons.py.
# Status-bar icons must be white-on-transparent; Android tints by alpha. # Status-bar icons must be white-on-transparent; Android tints by alpha.
save(transport("play", "white", 96), "ic_notify", RES) save(transport("play", "white", 96), "ic_notify", RES)
print(f"wrote {len(MENU) + len(TRANSPORT) + len(TOGGLES)} buttons to {RES} and {SHIP}") print(f"wrote {len(MENU) + len(TRANSPORT) + len(TOGGLES)} buttons to {RES} and {SHIP}")
+3 -5
View File
@@ -106,12 +106,10 @@ dock icon, uses the synced library automatically.)
## App icon ## App icon
_(written by LLM, cleaned up by me)_ _(written by LLM, cleaned up by me)_
You can change the app icon if you want.
`packaging/install-desktop.sh` installs the launcher entry and icon for your `packaging/install-desktop.sh` installs the launcher entry and icon for your
user (lets you pin LinTunes to the GNOME dash). The icon is just a file — user (lets you pin LinTunes to the GNOME dash). The icon is the same on the
replace `packaging/lintunes.png` (256×256 PNG) and re-run the script to use desktop and the Rabbit; GNOME caches icons, so if an old one lingers after
your own. GNOME caches icons, so if the old one lingers, log out and back in. re-running the script, log out and back in.
Unpinning from the dash does **not** uninstall LinTunes — it's still in the Unpinning from the dash does **not** uninstall LinTunes — it's still in the
GNOME app grid (open Activities and search "LinTunes"). Right-click it there → GNOME app grid (open Activities and search "LinTunes"). Right-click it there →
+1 -1
View File
@@ -1,3 +1,3 @@
"""LinTunes — iTunes-style music library manager and player for Linux.""" """LinTunes — iTunes-style music library manager and player for Linux."""
__version__ = "0.87.0" __version__ = "0.87.1"
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"version_name": "0.4.1", "version_code": 8} {"version_name": "0.4.2", "version_code": 9}
+18 -1
View File
@@ -191,7 +191,24 @@ def run_gui(data_dir: Path, files: list[Path],
exit_code = app.exec() exit_code = app.exec()
if window.restart_requested: if window.restart_requested:
return True # caller re-execs the updated code return True # caller re-execs the updated code
sys.exit(exit_code) leave(exit_code)
def leave(exit_code: int):
"""End the process once the event loop is done, without Python tearing
down the Qt objects. Everything is already saved by then (aboutToQuit
flushed the library, the player shut down), but a normal exit then
frees the QApplication's wrapper in no particular order, and sip touched
a QObject Qt had already deleted: a segfault and a core dump on every
quit (2026-10-27, 2026-11-06; four out of four on the dev library)."""
import logging
logging.shutdown()
for stream in (sys.stdout, sys.stderr):
try:
stream.flush()
except (OSError, ValueError):
pass
os._exit(exit_code)
if __name__ == "__main__": if __name__ == "__main__":
+3 -2
View File
@@ -1,15 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Install the lintunes .desktop entry and icon for the current user, so GNOME # Install the lintunes .desktop entry and icon for the current user, so GNOME
# shows a proper icon and the app can be pinned to the dash. # shows a proper icon and the app can be pinned to the dash.
# Re-run after swapping packaging/lintunes.png to update the icon.
set -euo pipefail set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APPS_DIR="$HOME/.local/share/applications" APPS_DIR="$HOME/.local/share/applications"
ICON_DIR="$HOME/.local/share/icons/hicolor/256x256/apps" ICON_DIR="$HOME/.local/share/icons/hicolor/512x512/apps"
mkdir -p "$APPS_DIR" "$ICON_DIR" mkdir -p "$APPS_DIR" "$ICON_DIR"
cp "$HERE/lintunes.png" "$ICON_DIR/lintunes.png" cp "$HERE/lintunes.png" "$ICON_DIR/lintunes.png"
# The icon used to install at 256x256; an old copy there would shadow this one.
rm -f "$HOME/.local/share/icons/hicolor/256x256/apps/lintunes.png"
# If lintunes isn't on PATH, point Exec at this checkout's module instead. # If lintunes isn't on PATH, point Exec at this checkout's module instead.
# We must NOT rely on the working directory: GNOME's dash launches apps via a # We must NOT rely on the working directory: GNOME's dash launches apps via a
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 812 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 338 KiB

+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
"""Make LinTunes' one app icon from packaging/lint.jpg: the picture squared
from its centre with its corners rounded at wave's radius (16 % of the
side), as packaging/lintunes.png (desktop, 512 px) and andTunes' launcher
(andtunes/app/src/main/res/drawable-nodpi/ic_launcher.png, 192 px) — the
same icon on both. Re-run after changing lint.jpg; the outputs are
committed, and the APK needs `andtunes/build.py --ship` to carry it."""
from pathlib import Path
from PIL import Image, ImageDraw
HERE = Path(__file__).resolve().parent.parent
SOURCE = HERE / "packaging" / "lint.jpg"
CORNER = 0.16 # corner radius, as a fraction of the side
DESKTOP = HERE / "packaging" / "lintunes.png"
ANDROID = (HERE / "andtunes" / "app" / "src" / "main" / "res"
/ "drawable-nodpi" / "ic_launcher.png")
def rounded(img: Image.Image, size: int) -> Image.Image:
img = img.convert("RGB").resize((size, size), Image.LANCZOS)
# Drawn at 4x and shrunk, so the corners are smooth rather than stepped.
big = size * 4
mask = Image.new("L", (big, big), 0)
ImageDraw.Draw(mask).rounded_rectangle(
(0, 0, big - 1, big - 1), radius=big * CORNER, fill=255)
out = img.convert("RGBA")
out.putalpha(mask.resize((size, size), Image.LANCZOS))
return out
def main() -> None:
src = Image.open(SOURCE)
side = min(src.size) # square it up from the centre
left, top = (src.width - side) // 2, (src.height - side) // 2
src = src.crop((left, top, left + side, top + side))
rounded(src, 512).save(DESKTOP)
rounded(src, 192).save(ANDROID)
print(f"Wrote {DESKTOP.relative_to(HERE)} and {ANDROID.relative_to(HERE)}.")
if __name__ == "__main__":
main()
+51
View File
@@ -0,0 +1,51 @@
"""Round 121: one app icon (packaging/lint.jpg, wave's corner radius) on the
desktop and the Rabbit, and quitting no longer segfaults."""
from pathlib import Path
from unittest.mock import patch
from PyQt6.QtGui import QImage
from lintunes import main
ROOT = Path(__file__).resolve().parents[1]
DESKTOP = ROOT / "packaging" / "lintunes.png"
ANDROID = (ROOT / "andtunes" / "app" / "src" / "main" / "res"
/ "drawable-nodpi" / "ic_launcher.png")
def _alpha(img: QImage, x: int, y: int) -> int:
return img.pixelColor(x, y).alpha()
def test_both_icons_are_the_same_picture_with_round_corners(qapp):
desktop, android = QImage(str(DESKTOP)), QImage(str(ANDROID))
assert (desktop.width(), desktop.height()) == (512, 512)
assert (android.width(), android.height()) == (192, 192)
for img in (desktop, android):
side = img.width()
for x, y in ((0, 0), (side - 1, 0), (0, side - 1), (side - 1, side - 1)):
assert _alpha(img, x, y) == 0 # corners cut away
assert _alpha(img, side // 2, 0) == 255 # edges kept
assert _alpha(img, side // 2, side // 2) == 255
# Wave's radius, 16 % of the side: inside it the corner is still
# clear just off the diagonal, past it the picture is solid.
r = round(side * 0.16)
assert _alpha(img, round(r * 0.2), round(r * 0.2)) == 0
assert _alpha(img, r, 1) == 255
small = desktop.scaled(192, 192).convertToFormat(QImage.Format.Format_ARGB32)
a = android.convertToFormat(QImage.Format.Format_ARGB32)
mid = small.pixelColor(96, 96), a.pixelColor(96, 96)
assert all(abs(c1 - c2) < 24 for c1, c2 in zip(mid[0].getRgb(), mid[1].getRgb()))
def test_the_launcher_is_not_drawn_by_make_buttons():
src = (ROOT / "andtunes" / "tools" / "make_buttons.py").read_text()
assert "def launcher" not in src
def test_leave_flushes_and_skips_python_teardown():
with patch.object(main.os, "_exit") as hard_exit, \
patch("logging.shutdown") as log_shutdown:
main.leave(3)
log_shutdown.assert_called_once()
hard_exit.assert_called_once_with(3)