宙斯 - 成分 - 错误
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了宙斯 - 成分 - 错误相关的知识,希望对你有一定的参考价值。
我使用Projucer(Juce v5.2.0)和xCode 9.2,当我在Slider上使用setLookAndFeel时,我有一些奇怪的错误。
我一步一步地学习该教程:https://www.youtube.com/watch?v=po46y8UKPOY&t=1020s
我制作完全相同的代码。在视频上没有问题。当我在电影的17:13持续时间内编译相同的代码时出现我的错误。
我的问题是:当我编译代码时一切正常,我编译的应用程序运行良好,“setLookAndFeel”按预期工作。但问题是当我关闭app时。然后应用程序看起来像关闭,但图标在停靠栏上,xCode显示“停止”按钮处于活动状态,所以看起来我的应用程序仍然以某种方式工作。 xCode自动将我带到一个名为“Juce Massage Thread(1)”的东西,并且有错误:Juce Message Thread (1): EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0
它就在那个代码的旁边:
jassert (masterReference.getNumActiveWeakReferences() == 0
|| (masterReference.getNumActiveWeakReferences() == 1
&& this == &getDefaultLookAndFeel()));
谁能帮助我?提前致谢。
答案
在断言之上有一个很大的注释块,你已经解释了为什么你会击中它:
/* 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)
,可能在其父组件的析构函数中。
以上是关于宙斯 - 成分 - 错误的主要内容,如果未能解决你的问题,请参考以下文章
xcxzcxzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx宙斯盾