Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed #65
Reverted 8b5141f
@BensonLaur @ish-kafel
#65 与
curAudioPos
关系不大,故撤销上一个提交(不过,没有为curAudioPos
赋初值的确会造成潜在的问题)。实际上,无论是哪一句歌词,只要
insertOffsetTime
大于音频的当前播放时间,由于盲目的计算time -= insertOffsetTime
,都会使计算出的时间戳为负值。注意,出现负值的根本原因是程序中数据类型的混乱,代码如下:
https://github.com/Beslyric-for-X/Beslyric-for-X/blob/8b5141f5ba94899ea2e6ae3fb235f0459abcf671/Entities/LyricMaker.cpp#L319-L337
证明:
quint64
类型最大值为18446744073709551615
,int
类型范围为-2147483648
到2147483647
,共4294967296
个数;18446744073709551615
进行两次除法运算(分别除以1000
和60
)后,值为307445734561825
;307445734561825 % 4294967296
,值为3385579553
,即对于unsigned int
类型,结果为3385579553
;int
类型(%.2d
),又因为3385579553
>2147483647
,所以结果为负数;3385579553 - 2147483647
结果为1238095906
,即从-2147483648
算起第 1238095906 个数,即-2147483648 + 1238095906 - 1
,结果为-909387743
。在搜索引擎里搜索
909387743
,能看到有多少歌词受到了这个 BUG 的影响。本 PR 能够帮助到未来的一个需求: #66 。