Git Product home page Git Product logo

Comments (5)

BensonLaur avatar BensonLaur commented on June 10, 2024 1

尝试解决定时器问题:
https://github.com/Beslyric-for-X/Beslyric-for-X/blob/de490e3d6cfe238097ac2c40cffff05807b6fa5b/Entities/MusicPlayer/musicPlayer.cpp#L761-L775

from beslyric-for-x.

pzhlkj6612 avatar pzhlkj6612 commented on June 10, 2024

行,算是临时修改吧。

有个问题,这里不需要判断 m_positionUpdateTimer.isActive() 了吗?

如果这里不需要,其他地方对其的判断是多余吗?

from beslyric-for-x.

BensonLaur avatar BensonLaur commented on June 10, 2024

我写的时候也有稍微想到这一点,应该也算是比较懒,直接认为如果定时器已经停止,再调用一次不会做任何动作。

不过你这么一问我倒是仔细注意了这个问题,不知道对已经停止的定时器调用stop会是什么结果?

from beslyric-for-x.

pzhlkj6612 avatar pzhlkj6612 commented on June 10, 2024

另外有一个问题。运行 de490e3 版本,歌曲播放结束时会输出:

QObject::killTimer: Timers cannot be stopped from another thread

测试了下, 收到 audioFinish 信号后执行的匿名函数是在 PlayThread 线程中执行的,所以会有这个警告。尽管 m_positionUpdateTimer 的确是停止了,但这或许会有隐患?


不过换用 QMetaObject::Connection QObject::connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type = Qt::AutoConnection) 方法能确保代码在 receiver 中执行,就像这样:

connect(playThread, SIGNAL(audioFinish(bool)), this, SLOT(theSlot(bool)));

void MusicPlayer::theSlot(bool isEndByForce) {
	m_positionUpdateTimer.stop();
}

from beslyric-for-x.

pzhlkj6612 avatar pzhlkj6612 commented on June 10, 2024

不过你这么一问我倒是仔细注意了这个问题,不知道对已经停止的定时器调用stop会是什么结果?

我在网上找了,没看到相关的说法,可以猜测定时器会继续保持停止状态。


另外, void QTimer::start() 倒是会使已开始工作的定时器停止并重新开始。

void QTimer::start() # QTimer Class | Qt Core 5.12.3

from beslyric-for-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.