From 71a22c6a121d1294a05ef35020c525fa70cae2fd Mon Sep 17 00:00:00 2001
From: Brianna Rainey
Date: Thu, 29 Jan 2026 14:50:29 -0500
Subject: v2.2.2 - fix flaky tests, fix UnboundLocalError in
MainWindow.createNewProject (#94)
* search more than one filename for compName
* remove extra QVBoxLayout
* insert default components using name instead of index
* bump version 2.2.1 to 2.2.2
* tests do not use `.config` for settings
Core.storeSettings() is no longer called as a side effect any time avp.core is imported. Thus the tests use a new `initCore` method and the normal user path now relies on entering via `cli.py`. This means certain toolkit functions (e.g., ones using `FFMPEG_BIN`) no longer work if imported from a different python script, unless they call Core.storeSettings() themselves to initialize the settings.ini file
* fix UnboundLocalError in createNewProject---
src/avp/__init__.py | 2 +-
src/avp/cli.py | 5 +
src/avp/command.py | 1 -
src/avp/components/spectrum.ui | 1686 ++++++++++++++++++++--------------------
src/avp/core.py | 14 +-
src/avp/gui/mainwindow.py | 10 +-
6 files changed, 857 insertions(+), 861 deletions(-)
(limited to 'src/avp')
diff --git a/src/avp/__init__.py b/src/avp/__init__.py
index a88bf10..9de9f93 100644
--- a/src/avp/__init__.py
+++ b/src/avp/__init__.py
@@ -3,7 +3,7 @@ import os
import logging
-__version__ = "2.2.1"
+__version__ = "2.2.2"
class Logger(logging.getLoggerClass()):
diff --git a/src/avp/cli.py b/src/avp/cli.py
index 02ceee6..0176f76 100644
--- a/src/avp/cli.py
+++ b/src/avp/cli.py
@@ -5,6 +5,11 @@ import re
import string
+from .core import Core
+
+# Core class must store settings as class variables
+# before we can use many things in AVP
+Core.storeSettings()
log = logging.getLogger("AVP.Main")
diff --git a/src/avp/command.py b/src/avp/command.py
index 7a77848..870391b 100644
--- a/src/avp/command.py
+++ b/src/avp/command.py
@@ -256,7 +256,6 @@ class Command(QtCore.QObject):
for i, compFileName in enumerate(compFileNames):
if name.lower() in compFileName:
return self.core.compNames[i]
- return
return None
diff --git a/src/avp/components/spectrum.ui b/src/avp/components/spectrum.ui
index c6a8a15..3bde075 100644
--- a/src/avp/components/spectrum.ui
+++ b/src/avp/components/spectrum.ui
@@ -27,909 +27,899 @@
-
-
-
- 4
-
+
-
-
+
+
+
+ 0
+ 0
+
+
+
+ Type
+
+
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Type
-
-
-
+
-
-
-
-
-
- Spectrum
-
-
- -
-
- Histogram
-
-
- -
-
- Vector Scope
-
-
- -
-
- Musical Scale
-
-
- -
-
- Phase
-
-
-
+
+ Spectrum
+
-
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 5
- 20
-
-
-
+
+ Histogram
+
-
-
-
-
- 0
- 0
-
-
-
- X
-
-
+
+ Vector Scope
+
-
-
-
-
- 0
- 0
-
-
-
-
- 80
- 16777215
-
-
-
- -10000
-
-
- 10000
-
-
+
+ Musical Scale
+
-
-
-
-
- 0
- 0
-
-
-
- Y
-
-
+
+ Phase
+
- -
-
-
-
- 0
- 0
-
-
-
-
- 80
- 16777215
-
-
-
-
- 0
- 0
-
-
-
- -10000
-
-
- 10000
-
-
- 0
-
-
-
-
+
-
-
-
-
-
-
- Compress
-
-
-
- -
-
-
- Mono
-
-
-
- -
-
-
- Mirror
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Hue
-
-
- 4
-
-
-
- -
-
-
- °
-
-
- 359
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Scale
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
- QAbstractSpinBox::UpDownArrows
-
-
- %
-
-
- 10
-
-
- 400
-
-
- 100
-
-
-
-
+
+
+ Qt::Orientation::Horizontal
+
+
+ QSizePolicy::Policy::Fixed
+
+
+
+ 5
+ 20
+
+
+
-
-
+
-
+
0
0
-
- false
+
+ X
-
- QFrame::NoFrame
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 80
+ 16777215
+
+
+
+ -10000
+
+
+ 10000
+
+
+
+ -
+
+
+
+ 0
+ 0
+
-
- QFrame::Plain
+
+ Y
-
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 80
+ 16777215
+
+
+
+
+ 0
+ 0
+
+
+
+ -10000
+
+
+ 10000
+
+
0
-
-
-
-
- 0
- 0
- 561
- 66
-
-
-
+
+
+
+
+ -
+
+
-
+
+
+ Compress
+
+
+
+ -
+
+
+ Mono
+
+
+
+ -
+
+
+ Mirror
+
+
+
+ -
+
+
+ Qt::Orientation::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Hue
+
+
+ 4
+
+
+
+ -
+
+
+ °
+
+
+ 359
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Scale
+
+
+ Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter
+
+
+
+ -
+
+
+ QAbstractSpinBox::ButtonSymbols::UpDownArrows
+
+
+ %
+
+
+ 10
+
+
+ 400
+
+
+ 100
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ false
+
+
+ QFrame::Shape::NoFrame
+
+
+ QFrame::Shadow::Plain
+
+
+ 0
+
+
+
+
+
+ 0
+ 0
+ 561
+ 76
+
+
+
+
+ QLayout::SizeConstraint::SetMaximumSize
+
+
+ 0
+
+
-
+
- QLayout::SetMaximumSize
-
-
- 0
+ QLayout::SizeConstraint::SetDefaultConstraint
-
-
-
- QLayout::SetDefaultConstraint
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 31
- 0
-
-
-
- Window
-
-
- 4
-
-
-
- -
-
-
-
-
- hann
-
-
- -
-
- gauss
-
-
- -
-
- tukey
-
-
- -
-
- dolph
-
-
- -
-
- cauchy
-
-
- -
-
- parzen
-
-
- -
-
- poisson
-
-
- -
-
- rect
-
-
- -
-
- bartlett
-
-
- -
-
- hanning
-
-
- -
-
- hamming
-
-
- -
-
- blackman
-
-
- -
-
- welch
-
-
- -
-
- flattop
-
-
- -
-
- bharris
-
-
- -
-
- bnuttall
-
-
- -
-
- lanczos
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Amplitude
-
-
- 4
-
-
-
- -
-
-
-
-
- Square root
-
-
- -
-
- Cubic root
-
-
- -
-
- 4thrt
-
-
- -
-
- 5thrt
-
-
- -
-
- Linear
-
-
- -
-
- Logarithmic
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::MinimumExpanding
-
-
-
- 10
- 20
-
-
-
-
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 31
+ 0
+
+
+
+ Window
+
+
+ 4
+
+
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Color
-
-
- 4
-
-
-
- -
-
-
-
-
- Channel
-
-
- -
-
- Intensity
-
-
- -
-
- Rainbow
-
-
- -
-
- Moreland
-
-
- -
-
- Nebulae
-
-
- -
-
- Fire
-
-
- -
-
- Fiery
-
-
- -
-
- Fruit
-
-
- -
-
- Cool
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::MinimumExpanding
-
-
-
- 10
- 20
-
-
-
-
-
+
+ -
+
+ hann
+
+
+ -
+
+ gauss
+
+
+ -
+
+ tukey
+
+
+ -
+
+ dolph
+
+
+ -
+
+ cauchy
+
+
+ -
+
+ parzen
+
+
+ -
+
+ poisson
+
+
+ -
+
+ rect
+
+
+ -
+
+ bartlett
+
+
+ -
+
+ hanning
+
+
+ -
+
+ hamming
+
+
+ -
+
+ blackman
+
+
+ -
+
+ welch
+
+
+ -
+
+ flattop
+
+
+ -
+
+ bharris
+
+
+ -
+
+ bnuttall
+
+
+ -
+
+ lanczos
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Amplitude
+
+
+ 4
+
+
+
+ -
+
+
-
+
+ Square root
+
+
+ -
+
+ Cubic root
+
+
+ -
+
+ 4thrt
+
+
+ -
+
+ 5thrt
+
+
+ -
+
+ Linear
+
+
+ -
+
+ Logarithmic
+
+
+
+
+ -
+
+
+ Qt::Orientation::Horizontal
+
+
+ QSizePolicy::Policy::MinimumExpanding
+
+
+
+ 10
+ 20
+
+
+
-
-
-
-
-
-
- -1
- -1
- 561
- 31
-
-
-
+
+ -
+
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Display Scale
-
-
- 4
-
-
-
- -
-
-
-
-
- Logarithmic
-
-
- -
-
- Square root
-
-
- -
-
- Cubic root
-
-
- -
-
- Linear
-
-
- -
-
- Reverse Log
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Amplitude
-
-
- 4
-
-
-
- -
-
-
-
-
- Logarithmic
-
-
- -
-
- Linear
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Minimum
-
-
-
- 40
- 20
-
-
-
-
-
+
+
+
+ 0
+ 0
+
+
+
+ Color
+
+
+ 4
+
+
+
+ -
+
+
-
+
+ Channel
+
+
+ -
+
+ Intensity
+
+
+ -
+
+ Rainbow
+
+
+ -
+
+ Moreland
+
+
+ -
+
+ Nebulae
+
+
+ -
+
+ Fire
+
+
+ -
+
+ Fiery
+
+
+ -
+
+ Fruit
+
+
+ -
+
+ Cool
+
+
+
+
+ -
+
+
+ Qt::Orientation::Horizontal
+
+
+ QSizePolicy::Policy::MinimumExpanding
+
+
+
+ 10
+ 20
+
+
+
-
-
-
-
-
-
- -1
- -1
- 585
- 64
-
-
-
+
+
+
+
+
+
+
+
+ -1
+ -1
+ 561
+ 36
+
+
+
+ -
+
-
-
-
-
-
-
- Mode
-
-
-
- -
-
-
-
-
- lissajous
-
-
- -
-
- lissajous_xy
-
-
- -
-
- polar
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Amplitude
-
-
- 4
-
-
-
- -
-
-
-
-
- Linear
-
-
- -
-
- Square root
-
-
- -
-
- Cubic root
-
-
- -
-
- Logarithmic
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
+
+
+
+ 0
+ 0
+
+
+
+ Display Scale
+
+
+ 4
+
+
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Zoom
-
-
- 4
-
-
-
- -
-
-
- 1
-
-
- 10
-
-
-
- -
-
-
- Line
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
+
+ -
+
+ Logarithmic
+
+
+ -
+
+ Square root
+
+
+ -
+
+ Cubic root
+
+
+ -
+
+ Linear
+
+
+ -
+
+ Reverse Log
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Amplitude
+
+
+ 4
+
+
+
+ -
+
+
-
+
+ Logarithmic
+
+
+ -
+
+ Linear
+
+
+
+
+ -
+
+
+ Qt::Orientation::Horizontal
+
+
+ QSizePolicy::Policy::Minimum
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -1
+ -1
+ 585
+ 76
+
+
+
+ -
+
+
-
+
+
+ Mode
+
+
+
+ -
+
+
-
+
+ lissajous
+
+
+ -
+
+ lissajous_xy
+
+
+ -
+
+ polar
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Amplitude
+
+
+ 4
+
+
+
+ -
+
+
-
+
+ Linear
+
+
+ -
+
+ Square root
+
+
+ -
+
+ Cubic root
+
+
+ -
+
+ Logarithmic
+
+
+
+
+ -
+
+
+ Qt::Orientation::Horizontal
+
+
+
+ 40
+ 20
+
+
+
-
-
-
-
-
-
- 0
- 0
- 561
- 31
-
-
-
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Zoom
+
+
+ 4
+
+
+
+ -
+
+
+ 1
+
+
+ 10
+
+
+
+ -
+
+
+ Line
+
+
+
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Timeclamp
-
-
- 4
-
-
-
- -
-
-
- s
-
-
- 3
-
-
- 0.002000000000000
-
-
- 1.000000000000000
-
-
- 0.010000000000000
-
-
- 0.017000000000000
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
+
+
+ Qt::Orientation::Horizontal
+
+
+
+ 40
+ 20
+
+
+
-
-
-
-
-
-
- 0
- 0
- 551
- 31
-
-
-
+
+
+
+
+
+
+
+
+ 0
+ 0
+ 561
+ 36
+
+
+
+ -
+
-
-
+
+
+
+ 0
+ 0
+
+
+
+ Timeclamp
+
+
+ 4
+
+
+
+ -
+
+
+ s
+
+
+ 3
+
+
+ 0.002000000000000
+
+
+ 1.000000000000000
+
+
+ 0.010000000000000
+
+
+ 0.017000000000000
+
+
+
+ -
+
+
+ Qt::Orientation::Horizontal
+
+
+
+ 40
+ 20
+
+
+
-
-
+
+
-
-
+
+
+
+
+
+ 0
+ 0
+ 551
+ 31
+
+
+
+ -
+
+
+
+
+
+
-
- Qt::Vertical
+ Qt::Orientation::Vertical
- QSizePolicy::Fixed
+ QSizePolicy::Policy::Fixed
diff --git a/src/avp/core.py b/src/avp/core.py
index 099b0b4..1e9a9c3 100644
--- a/src/avp/core.py
+++ b/src/avp/core.py
@@ -420,14 +420,18 @@ class Core:
Core.canceled = False
@classmethod
- def storeSettings(cls):
+ def storeSettings(cls, dataDir=None):
"""Store settings/paths to directories as class variables"""
from .__init__ import wd
from .toolkit.ffmpeg import findFfmpeg
cls.wd = wd
- dataDir = QtCore.QStandardPaths.writableLocation(
- QtCore.QStandardPaths.StandardLocation.AppConfigLocation
+ dataDir = (
+ QtCore.QStandardPaths.writableLocation(
+ QtCore.QStandardPaths.StandardLocation.AppConfigLocation
+ )
+ if dataDir is None
+ else dataDir
)
# Windows: C:/Users//AppData/Local/audio-visualizer
# macOS: ~/Library/Preferences/audio-visualizer
@@ -589,7 +593,3 @@ class Core:
libLog.addHandler(libLogFile)
# lowest level must be explicitly set on the root Logger
libLog.setLevel(0)
-
-
-# always store settings in class variables even if a Core object is not created
-Core.storeSettings()
diff --git a/src/avp/gui/mainwindow.py b/src/avp/gui/mainwindow.py
index 5a051fd..3221783 100644
--- a/src/avp/gui/mainwindow.py
+++ b/src/avp/gui/mainwindow.py
@@ -414,8 +414,10 @@ class MainWindow(QtWidgets.QMainWindow):
# Add initial components if none are in the list
if not self.core.selectedComponents:
- self.core.insertComponent(0, 0, self)
- self.core.insertComponent(1, 1, self)
+ self.core.insertComponent(
+ 0, self.core.moduleIndexFor("Classic Visualizer"), self
+ )
+ self.core.insertComponent(1, self.core.moduleIndexFor("Color"), self)
# set colors to white and black to match classic appearance of program
self.core.selectedComponents[0].page.lineEdit_visColor.setText(
"255,255,255"
@@ -900,8 +902,8 @@ class MainWindow(QtWidgets.QMainWindow):
def createNewProject(self, prompt=True):
if prompt:
ch = self.openSaveChangesDialog("starting a new project")
- if ch is None:
- return
+ if ch is None:
+ return
self.clear()
self.currentProject = None
--
cgit v1.2.3