# CriticalSection crashes with VS 2022

**URL:** <https://forum.juce.com/t/criticalsection-crashes-with-vs-2022/63737>\
**Category:** Windows\
**Created:** [October 6, 2024, 1:16pm UTC](https://forum.juce.com/t/criticalsection-crashes-with-vs-2022/63737 "2024-10-06T13:16:11Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![kunz](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kunz](https://forum.juce.com/u/kunz)\
**Post date:** [October 10, 2024, 7:20am UTC](https://forum.juce.com/t/criticalsection-crashes-with-vs-2022/63737/23 "2024-10-10T07:20:57Z")

</div>

> [@eyalamir](#):
>
> We probably need to discuss the design that leads you to such problems. 🙂

This is true. When you set up it the right way, you can eliminate the singleton lifetime problems.

There is one problem I wasn’t able to fix:

> [@LookAndFeel\_V4 difficulties applying Typeface to just one component](https://forum.juce.com/t/lookandfeel-v4-difficulties-applying-typeface-to-just-one-component/44018):
>
> I am having trouble following the [LookAndFeel Tutorial](https://docs.juce.com/master/tutorial_look_and_feel_customisation.html). According to the “Cusomizing Color” Section, I coded this: in My Component.h: private: juce::LookAndFeel\_V4 m\_LookAndFeelIcons; and in it’s constructor: m\_LookAndFeelIcons.setDefaultSansSerifTypeface(MyBinaryAssets::MyTypeFace); someBTN.setLookAndFeel(&m\_LookAndFeelIcons); But the Button does not change it’s font…? When I do something like: someBTN.getLookAndFeel().setDefaultSansSerifTypeface(MyBinaryAssets::MyTypeFac…

It looks like it is not possible to set a different LookAndFeel with other typefaces to a specific component. Some weird singleton magic happens in the background.

> [@eyalamir](#):
>
> As a plugin developer you want to save user resources at any junction you can, and the memory for shared resources is a easy win that would greatly benefit your users in projects with many plugins, don’t prevent them from having it. 🙂

I agree 🙂

A short resume:  
Singletons are useful in the plug-in world when you share resources and solve technical problems. But they are a bad design choice otherwise.

---

_[View the full topic](https://forum.juce.com/t/criticalsection-crashes-with-vs-2022/63737)._
