Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous bugfixes #186

Merged
merged 26 commits into from
Dec 17, 2024
Merged

Miscellaneous bugfixes #186

merged 26 commits into from
Dec 17, 2024

Conversation

arch1t3cht
Copy link
Member

Various bugfixes that accumulated at arch1t3cht/Aegisub. This one is a bit more involved but can again be checked commit for commit.

Float edits with a spinner are sized to fit their full min-max range
of possible values, so after wx stopped displaying large values in
scientific notation, many float edits would be drawn far too wide.
This commit makes min and max default to 0 and 100 (matching wx's
defaults) instead of -DOUBLE_MAX and DOUBLE_MAX.

Note that this does change the behavior of lua dialogs, but does not
contradict existing documentation or specification. It should only
affect scripts who either disobey the specification by specifying only
one value out of max/min, or scripts displaying these large float edits
by specifing a step, but no max or min.
These were giving false negatives on samba shares, which broke the font
collector. Windows also recommends to not use access checks in these
cases, and instead just see if the operations succeeds or not.
These alignment flags would cause an assertion error
"Horizontal alignment flags are ignored in horizontal sizers"
when opening the dialog (mainly when importing styles from another
script).
As the assertion error says, the flags are ignored anyway, so they're
safe to remove.
@@ -286,6 +286,10 @@ namespace Automation4 {
max = DBL_MAX;
min = -DBL_MAX;
}
if (step != 0.0) {
min = min == -DBL_MAX ? 0.0 : min;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this impact any scripts that you know of seeing significant use? In particular, if it's anything we can fix preemptively in TSTools we should.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/auto4_lua.cpp Outdated Show resolved Hide resolved
libaegisub/common/vfr.cpp Show resolved Hide resolved
src/auto4_base.cpp Show resolved Hide resolved
src/auto4_lua_dialog.cpp Show resolved Hide resolved
arch1t3cht and others added 18 commits December 17, 2024 15:32
When cancelling an automation macro from the progress dialog, the dialog
throws a UserCancelException. If the macro still runs to the end
afterwards (instead of calling aegisub.cancel or causing an exception),
the return values are left on the stack. This causes assertion errors
due to check_stack when those are enabled.
To see how the previous implementation was faulty, see either the added
tests, or
- In Aegisub, open a dummy video with a frame rate of 23.976
- Make a subtitle event with start time 04:44.41
- Double-click the line to (supposedly) seek to its first frame
- This will seek one frame earlier than it should, and the event will
  not be displayed on the resulting frame.

The new formula is the mathematical inverse of the TimeAtFrame formula
(for the EXACT case). The derivation is the following:

FrameAtTime(ms, EXACT) should be the largest possible integer `frame`
such that:

ms >= floor(((frame - timecodes.size() + 1) * 1000 * denominator + last + floor(numerator / 2)) / numerator)

where `/` denotes division of real numbers (i.e. without rounding down).
The expression on the right is the formula used in TimeAtFrame.
This inequality can be transformed as follows:

ms >= floor(((frame - timecodes.size() + 1) * 1000 * denominator + last + floor(numerator / 2)) / numerator)

((frame - timecodes.size() + 1) * 1000 * denominator + last + floor(numerator / 2)) / numerator < ms + 1

(frame - timecodes.size() + 1) * 1000 * denominator + last + floor(numerator / 2) < (ms + 1) * numerator

(frame - timecodes.size() + 1) * 1000 * denominator < (ms + 1) * numerator - last - floor(numerator / 2)

frame - timecodes.size() + 1 < ((ms + 1) * numerator - last - floor(numerator / 2)) / (1000 * denominator)

frame - timecodes.size() + 1 < ceil(((ms + 1) * numerator - last - floor(numerator / 2)) / (1000 * denominator))

frame - timecodes.size() + 1 < floor(((ms + 1) * numerator - last - floor(numerator / 2) + (1000 * denominator - 1)) / (1000 * denominator))

frame < floor(((ms + 1) * numerator - last - floor(numerator / 2) + (1000 * denominator - 1)) / (1000 * denominator)) + timecodes.size() - 1

frame <= floor(((ms + 1) * numerator - last - floor(numerator / 2) + (1000 * denominator - 1)) / (1000 * denominator)) + timecodes.size() - 2

Since we are looking for the largest integer `frame` satisfying this
inequality, FrameAtTime(ms, EXACT) must be equal to the right-hand side
in the last inequality.
The percent values used for the overscan masks follow the BBC's
guidelines, as in
https://en.wikipedia.org/wiki/Overscan#Overscan_amounts .
However, these measure the per-side width as opposed to the total
percentage of width/height being cut off. Thus, they should not be
divided by two when drawing the mask.
This fixes a crash on Windows when double-clicking the draggable
separator between the column headers "Command" and "Description" in the
hotkey configuration dialog.
... ever wondered why you can't drag .webm files into Aegisub?
This is why.
It should not be in alt-dragging mode by default.

Fix #32
wx doesn't seem to like the dialogs being created on some other worker
thread, which makes file dialogs opened by lua scripts crash in various
ways on Linux. Doing everything on the main thread hopefully fixes this.

Fixes #51 .
Previously different menus may use conflict ids in range 10000~.

Fix #53
See also Aegisub#131
These commands were revamped in 0ef9963 but the default hotkeys were
never updated. The hotkeys were automatically migrated, but resetting
the settings back to defaults would still set invalid settings.
msg can be nil, which would previously error out when trying to print it.
IsConversionSupported unconditionally calls iconv_close on the
descriptor returned by iconv_open. This may result in crashes if
iconv_open returns iconv_invalid.
@arch1t3cht arch1t3cht force-pushed the misc_bugfixes branch 2 times, most recently from 4f66435 to 8760c3a Compare December 17, 2024 17:34
This would cause an assertion failure in functions like lua_for_each
when the given closure throws an error and thus leaves some values on
the stack. This can make Aegisub crash entirely instead of just catching
and reporting the error. Instead, these stack_checks can be done
manually.
@CoffeeFlux CoffeeFlux merged commit 374ea92 into master Dec 17, 2024
5 checks passed
@arch1t3cht arch1t3cht deleted the misc_bugfixes branch December 18, 2024 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants