Skip to content

Commit 2307f69

Browse files
authored
Merge pull request #1828 from 4shadoww/master
Fix Spotify search and SDL3 crash
2 parents c028948 + 7a6b691 commit 2307f69

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/tauon/t_modules/t_draw.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import logging
2424
import math
2525
import sys
26-
from ctypes import c_bool, c_int, c_size_t, pointer
26+
from ctypes import c_bool, c_float, byref, c_size_t, pointer
2727
from typing import TYPE_CHECKING
2828

2929
import sdl3
@@ -111,11 +111,11 @@ def prime(self) -> None:
111111
texture = sdl3.SDL_CreateTextureFromSurface(self.renderer, self.surface)
112112
sdl3.SDL_DestroySurface(self.surface)
113113
self.surface = None
114-
tex_w = pointer(c_int(0))
115-
tex_h = pointer(c_int(0))
116-
sdl3.SDL_QueryTexture(texture, None, None, tex_w, tex_h)
117-
self.rect.w = int(tex_w.contents.value)
118-
self.rect.h = int(tex_h.contents.value)
114+
tex_w = c_float(0.0)
115+
tex_h = c_float(0.0)
116+
sdl3.SDL_GetTextureSize(texture, byref(tex_w), byref(tex_h))
117+
self.rect.w = int(tex_w.value)
118+
self.rect.h = int(tex_h.value)
119119
self.texture = texture
120120

121121
def draw(self, x: int, y: int) -> bool | None:
@@ -131,7 +131,7 @@ def draw(self, x: int, y: int) -> bool | None:
131131
self.prime()
132132
self.rect.x = round(x)
133133
self.rect.y = round(y)
134-
sdl3.SDL_RenderCopy(self.renderer, self.texture, None, self.rect)
134+
sdl3.SDL_RenderTexture(self.renderer, self.texture, None, self.rect)
135135

136136
return True
137137

@@ -842,12 +842,12 @@ def __draw_text_windows(
842842
ke = sdl3.SDL_MapRGB(s_image.contents.format, bg.r, bg.g, bg.b)
843843
sdl3.SDL_SetColorKey(s_image, True, ke)
844844
c = sdl3.SDL_CreateTextureFromSurface(self.renderer, s_image)
845-
tex_w = pointer(c_int(0))
846-
tex_h = pointer(c_int(0))
847-
sdl3.SDL_QueryTexture(c, None, None, tex_w, tex_h)
845+
tex_w = c_float(0.0)
846+
tex_h = c_float(0.0)
847+
sdl3.SDL_GetTextureSize(c, byref(tex_w), byref(tex_h))
848848
dst = sdl3.SDL_FRect(round(x), round(y))
849-
dst.w = int(tex_w.contents.value)
850-
dst.h = int(tex_h.contents.value)
849+
dst.w = int(tex_w.value)
850+
dst.h = int(tex_h.value)
851851

852852
sdl3.SDL_DestroySurface(s_image)
853853
#im.close()

src/tauon/t_modules/t_spot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ def search(self, text: str) -> list[TrackClass] | None:
370370

371371
if results[0]:
372372
for i, album in enumerate(results[0].items[1:]):
373+
if hasattr(album, "album"):
374+
album = album.album
375+
373376
img = QuickThumbnail(self.tauon)
374377
img.url = album.images[-1].url
375378
img.size = round(50 * self.tauon.gui.scale)

0 commit comments

Comments
 (0)