Bug 513005

Summary: SelectChapterTags.qml produces a QT error and `kid3-cli` exits prematurely.
Product: [Applications] kid3 Reporter: Molly Messner <obskyr>
Component: generalAssignee: Urs Fleisch <ufleisch>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: 3.9.x   
Target Milestone: ---   
Platform: Other   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Molly Messner 2025-12-06 12:37:02 UTC
SUMMARY

The “select chapter tags” QML script now produces a QT error and `kid3-cli` exits prematurely.


STEPS TO REPRODUCE
1. Run the command: `kid3-cli -c "select 'anything.mp3'" -c "execute @qml '<KID3 LOCATION HERE>\qml\script\SelectChapterTags.qml'"


OBSERVED RESULT

The following error is produced, and `kid3-cli` exits prematurely, and any tagging attempted to do in commands thereafter is unsuccessful:

```
qt.qml.typeregistration: Invalid QML element name "Frame"; value type names should begin with a lowercase letter
qt.qml.typeregistration: Invalid QML element name "FrameNotice"; value type names should begin with a lowercase letter
When matching arguments for Kid3Application::tagsToFrameModels():

Too many arguments, ignoring 2
```
Comment 1 Molly Messner 2025-12-06 12:38:46 UTC
(Oop, I forgot to mention: This behavior was observed in PowerShell 7.5.4 on Windows 11 with Kid3 version 3.9.7.)
Comment 2 Urs Fleisch 2025-12-10 20:18:08 UTC
The first two output lines "qt.qml..." can be ignored, they are from Qt and unfortunately cannot be suppressed.
I do not get the other error "When matching arguments for Kid3Application::tagsToFrameModels(), Too many arguments, ignoring 2" on Linux, and I do not have a machine which is "good enough" for Windows 11.
Does it also happen when run from the UI via a user action?
Could you try with the backslashes in the path replaced by normal slashes?
Comment 3 Urs Fleisch 2025-12-13 14:36:02 UTC
I think that I have found the reason for the problem. The Qt errors are just annoying and probably not the cause, which is a bit more complicated, so I reproduce my commit message below (currently on the devel branch). Please test with version git20251213 from https://sourceforge.net/projects/kid3/files/kid3/development/.

https://invent.kde.org/ufleisch/kid3/-/commit/2d7800e071fc0e39ff9fefb4356d2cd3f02ea171

SelectChapterTags.qml: Support multi command kid3-cli invocation

When running SelectChapterTags.qml as an intermediate step of a
kid3-cli invocation, e.g.

kid3-cli \
  -c "execute @qml /usr/share/kid3/qml/script/SelectChapterTags.qml --deselect" \
  -c remove \
  track.mp3

the problem is that the QML script is run in stand-alone mode,
i.e. it reads the current folder and forgets about the current
selection, in this case the file track.mp3. In this example the
subsequent "remove" step operated on an empty selection thus
doing nothing.

For other use cases, stand-alone is the desired mode, e.g. using

kid3-cli -c "execute @qml '/path/to/file.qml'"

as a means to run a Kid3-QML-script without needing another
executable such as qml or qmlscene. So the current behavior
is not changed, but it is now possible to pass "--standalone=false"
to the QML script to explicitly set the mode. In the case of
SelectChapterTags.qml, running in stand-alone mode does not
make sense, to this is now switched off by overriding the
isStandalone() method in the script.

Moreover, the output
"When matching arguments for Kid3Application::tagsToFrameModels():
Too many arguments, ignoring 2", which is annoying but probably
not causing a problem is suppressed by wrapping the receiving
slot function into a function without arguments.