我使用Projucer (Juce v5.2.0)和xCode 9.2,当我在幻灯片上使用setLookAndFeel时,我遇到了一些奇怪的错误。
我将一步一步地学习该教程:https://www.youtube.com/watch?v=po46y8UKPOY&t=1020s
我写的是完全相同的代码。在视频上没有任何问题。当我编译与电影17:13时长相同的代码时,我的错误就会出现。
我的问题是:当我编译代码时,一切都正常,我编译的应用程序工作得很好,"setLookAndFeel“的工作与预期的一样。但问题是当我关闭应用程序时。然后应用程序看起来像是关闭的,但图标在被子上,xCode显示“停止”按钮处于活动状态,所以看起来我的应用程序在某种程度上仍然有效。xCode自动把我带到一个叫做"Juce Massage (1)“的地方,出现了一个错误:Juce Message Thread (1): EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0
它紧挨着这个代码:
jassert (masterReference.getNumActiveWeakReferences() == 0
|| (masterReference.getNumActiveWeakReferences() == 1
&& this == &getDefaultLookAndFeel()));有人能帮帮我吗?提前谢谢。
发布于 2017-12-29 18:55:47
在你点击的断言上方有一个很大的注释块,解释了你点击它的原因:
/* This assertion is triggered if you try to delete a LookAndFeel object while something
is still using it!
Reasons may be:
- it's still being used as the default LookAndFeel; or
- it's set as a Component's current lookandfeel; or
- there's a WeakReference to it somewhere else in your code
Generally the fix for this will be to make sure you call
Component::setLookandFeel (nullptr) on any components that were still using
it before you delete it, or call LookAndFeel::setDefaultLookAndFeel (nullptr)
if you had set it up to be the default one. This assertion can also be avoided by
declaring your LookAndFeel object before any of the Components that use it as
the LookAndFeel will be destroyed before the Components.
Deleting a LookAndFeel is unlikely to cause a crash since most things will use a
safe WeakReference to it, but it could cause some unexpected graphical behaviour,
so it's advisable to clear up any references before destroying them!
*/因此,在删除滑块之前,您需要在滑块上调用setLookAndFeel (nullptr),可能是在其父组件的析构函数中。
https://stackoverflow.com/questions/47846074
复制相似问题