Skip to content

Commit 5bbcd75

Browse files
committed
Fix for missing QtMultimedia module
Some Qts don't have the tech for QtMediaPlayer, and I typo'd myself into raising an exception in this situation
1 parent 4bac117 commit 5bbcd75

6 files changed

Lines changed: 22 additions & 11 deletions

File tree

docs/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ title: Changelog
5353
### nicer PIL memory cleanup
5454

5555
* PIL images are now closed promptly (freeing up memory better and faster) in more locations: the visual tuning suite; jpeg quality estimation; icc profile inspection; embedded metadata inspection; exif inspection; decompression bomb testing; 'show file metadata' window; import metadata gen; icc profile inspection on load; on forced PIL loads that error out on conversion to numpy; on another standard method to load images; variable frame duration fetching, 'get number of times to play animation'; 'animation has valid duration'; serialisable object import; ugoira rendering; ugoira API rendering; ugoira property fetch; ugoira json property fetch; Ugoira thumb gen; PSD rendering; PSD thumb gen; the native PIL animation renderer; on EXIF rotation conversion; some weird dequantization; resolution fetch; when some thumbnail stuff errors out; some animation property fetch; OpenXML thumbnail gen; Paint.NET thumb gen; Krita thumb gen; Krita rendering; openraster thumb gen; openraster rendering
56-
* I went overkill here and yet there are still some gaps. I got all the file loads though, I think, which is the main stuff here that I thtink was lagging. some of it is also a little ugly. we'll see if this improves some lazy memory cleanup during heavy import. if it helps, I may revisit to clean up
56+
* I went overkill here and yet there are still some gaps. I got all the file loads though, I think, which is the main stuff here that I think was lagging. some of it is also a little ugly. we'll see if this improves some lazy memory cleanup during heavy import. if it helps, I may revisit to clean up
5757

5858
### import options overhaul
5959

docs/old_changelog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ <h2 id="version_665"><a href="#version_665">version 665</a></h2>
7272
<li>removed Qt5 QKeySequence conversion</li>
7373
<li><h3>nicer PIL memory cleanup</h3></li>
7474
<li>PIL images are now closed promptly (freeing up memory better and faster) in more locations: the visual tuning suite; jpeg quality estimation; icc profile inspection; embedded metadata inspection; exif inspection; decompression bomb testing; 'show file metadata' window; import metadata gen; icc profile inspection on load; on forced PIL loads that error out on conversion to numpy; on another standard method to load images; variable frame duration fetching, 'get number of times to play animation'; 'animation has valid duration'; serialisable object import; ugoira rendering; ugoira API rendering; ugoira property fetch; ugoira json property fetch; Ugoira thumb gen; PSD rendering; PSD thumb gen; the native PIL animation renderer; on EXIF rotation conversion; some weird dequantization; resolution fetch; when some thumbnail stuff errors out; some animation property fetch; OpenXML thumbnail gen; Paint.NET thumb gen; Krita thumb gen; Krita rendering; openraster thumb gen; openraster rendering</li>
75-
<li>I went overkill here and yet there are still some gaps. I got all the file loads though, I think, which is the main stuff here that I thtink was lagging. some of it is also a little ugly. we'll see if this improves some lazy memory cleanup during heavy import. if it helps, I may revisit to clean up</li>
75+
<li>I went overkill here and yet there are still some gaps. I got all the file loads though, I think, which is the main stuff here that I think was lagging. some of it is also a little ugly. we'll see if this improves some lazy memory cleanup during heavy import. if it helps, I may revisit to clean up</li>
7676
<li><h3>import options overhaul</h3></li>
7777
<li>wrote migration code that takes the old file/tag/note import options and produces a new populated `ImportOptionsContainer`</li>
7878
<li>updated the prefetch import options to track the 'fetch metadata even...' checkboxes, although they will do nothing until migration</li>

hydrus/client/gui/ClientGUI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8658,7 +8658,7 @@ def ReleaseMPVWidget( self, mpv_widget: ClientGUIMPV.MPVWidget ):
86588658
self._persistent_mpv_widgets.append( mpv_widget )
86598659

86608660

8661-
def _UnloadAndPurgeQtMediaPlayer( self, qt_media_player: ClientGUIQtMediaPlayer.QtMediaPlayer):
8661+
def _UnloadAndPurgeQtMediaPlayer( self, qt_media_player: ClientGUIQtMediaPlayer.QtMediaPlayer ):
86628662

86638663
if qt_media_player.IsCompletelyUnloaded():
86648664

hydrus/client/gui/ClientGUIAboutWindow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def render_availability_line( name: str, is_ok: bool, is_module_not_found: bool,
2424

2525
else:
2626

27-
HydrusData.ShowText( f'Module {name} failed to import because of the following:' )
27+
HydrusData.ShowText( f'Hey, one of your optional modules, "{name}", did not load, and the error is more complicated than "you do not have it". The error was:' )
2828
HydrusData.ShowText( error_trace )
2929

3030
if name == 'mpv' and 'sio_flush' in error_trace:
@@ -61,6 +61,7 @@ def ShowAboutWindow( win: QW.QWidget ):
6161
from hydrus.client import ClientTime
6262
from hydrus.client.gui import ClientGUICharts
6363
from hydrus.client.gui.canvas import ClientGUIMPV
64+
from hydrus.client.gui.canvas import ClientGUIQtMediaPlayer
6465
from hydrus.client.networking import ClientNetworkingDomainTLDExtract
6566
from hydrus.client.parsing import ClientParsing
6667

@@ -225,6 +226,7 @@ def ShowAboutWindow( win: QW.QWidget ):
225226
availability_lines.append( render_availability_line( 'lxml', ClientParsing.LXML_IS_OK, not ClientParsing.LXML_IS_OK, '' ) )
226227
availability_lines.append( render_availability_line( 'lz4', HydrusCompression.LZ4_OK, not HydrusCompression.LZ4_OK, '' ) )
227228
availability_lines.append( render_availability_line( 'olefile', HydrusOLEHandling.OLEFILE_OK, not HydrusOLEHandling.OLEFILE_OK, '' ) )
229+
availability_lines.append( render_availability_line( 'QtMultimedia', ClientGUIQtMediaPlayer.QT_MULTIMEDIA_IS_AVAILABLE, ClientGUIQtMediaPlayer.QT_MULTIMEDIA_MODULE_NOT_FOUND, ClientGUIQtMediaPlayer.QT_MULTIMEDIA_IMPORT_ERROR ) )
228230
availability_lines.append( render_availability_line( 'tldextract (under testing)', ClientNetworkingDomainTLDExtract.TLDEXTRACT_OK, ClientNetworkingDomainTLDExtract.TLDEXTRACT_MODULE_NOT_FOUND, ClientNetworkingDomainTLDExtract.TLDEXTRACT_IMPORT_ERROR ) )
229231

230232
#

hydrus/client/gui/canvas/ClientGUICanvasMedia.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,12 @@ def _MakeMediaWindow( self ):
16961696

16971697
HydrusData.ShowText( 'MPV is not available!' )
16981698

1699+
elif self._show_action == CC.MEDIA_VIEWER_ACTION_SHOW_WITH_QTMEDIAPLAYER and not ClientGUIQtMediaPlayer.QT_MULTIMEDIA_IS_AVAILABLE:
1700+
1701+
self._show_action = CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON
1702+
1703+
HydrusData.ShowText( 'QtMediaPlayer is not available!' )
1704+
16991705

17001706
if self._show_action in ( CC.MEDIA_VIEWER_ACTION_DO_NOT_SHOW_ON_ACTIVATION_OPEN_EXTERNALLY, CC.MEDIA_VIEWER_ACTION_DO_NOT_SHOW ):
17011707

hydrus/client/gui/canvas/ClientGUIQtMediaPlayer.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1+
import traceback
12
import typing
23

34
from qtpy import QtCore as QC
45
from qtpy import QtWidgets as QW
56
from qtpy import QtGui as QG
67

7-
QT_MULTIMEDIA_OK = False
8+
QT_MULTIMEDIA_IS_AVAILABLE = True
9+
QT_MULTIMEDIA_MODULE_NOT_FOUND = False
10+
QT_MULTIMEDIA_IMPORT_ERROR = 'QtMultimedia seems fine!'
811

912
try:
1013

1114
from qtpy import QtMultimediaWidgets as QMW
1215
from qtpy import QtMultimedia as QM
1316

14-
QT_MULTIMEDIA_OK = True
17+
except Exception as e_qt_m:
1518

16-
except Exception as e:
17-
18-
pass
19+
QT_MULTIMEDIA_IS_AVAILABLE = False
20+
QT_MULTIMEDIA_MODULE_NOT_FOUND = isinstance( e_qt_m, ModuleNotFoundError )
21+
QT_MULTIMEDIA_IMPORT_ERROR = traceback.format_exc()
1922

2023

2124
from hydrus.core import HydrusConstants as HC
@@ -35,9 +38,9 @@
3538
from hydrus.client.gui.canvas import ClientGUICanvas
3639

3740

38-
def GetAvailableAudioDevices() -> list[ QM.QAudioDevice ]:
41+
def GetAvailableAudioDevices() -> "list[ QM.QAudioDevice ]":
3942

40-
if not QT_MULTIMEDIA_OK:
43+
if not QT_MULTIMEDIA_IS_AVAILABLE:
4144

4245
return []
4346

0 commit comments

Comments
 (0)