Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
LV2Validator::UI Struct Reference

#include <LV2Validator.h>

Public Member Functions

void Destroy ()
 
 ~UI ()
 

Public Attributes

SuilInstancePtr mSuilInstance
 
wxWindowPtr< NativeWindowmNativeWin {}
 
bool mJustLeakMemory { false }
 

Detailed Description

Definition at line 132 of file LV2Validator.h.

Constructor & Destructor Documentation

◆ ~UI()

LV2Validator::UI::~UI ( )
inline

Definition at line 134 of file LV2Validator.h.

134{ Destroy(); }

References Destroy().

Here is the call graph for this function:

Member Function Documentation

◆ Destroy()

void LV2Validator::UI::Destroy ( )

Definition at line 51 of file LV2Validator.cpp.

52{
53#ifdef __WXMAC__
54 // Issue 3222: x42-limiter does an unbalanced release somewhere, requiring
55 // the host to add an extra reference. But other plug-ins don't expect
56 // that.
57 // This is how we can accommodate them either way.
58
59 const auto widget = (mNativeWin && mSuilInstance)
60 ? static_cast<WXWidget>(suil_instance_get_widget(mSuilInstance.get()))
61 : nullptr;
62 if (widget) {
63 if (!mJustLeakMemory) {
64 // Bump reference count twice
65 wxCFRetain(widget);
66 wxCFRetain(widget);
67 }
68 else {
69 // Compensates for either an unbalanced release, or (when closing the
70 // project while the dialog is open) dangling pointers remaining after
71 // the last release, by adding one release. In the second case, it
72 // leaks resources.
73 // (We can't detect here, which of the two cases applies.)
74 wxCFRetain(widget);
75 }
76
77 // Do destruction of mNativeWin, which points to widget, and the suil
78 // instance in the scope of an autorelease pool
79 {
80 wxMacAutoreleasePool pool;
81 mNativeWin = nullptr;
82 mSuilInstance.reset();
83 // Deferred releases are forced to happen here, not later up the stack
84 // in the enclosing wxMacAutoreleasePool given by wxWidgets
85 }
86
87 // Two increases of the reference count means there can be one unbalanced
88 // release and yet we can still query the use-count safely
89 if (!mJustLeakMemory) {
90 int count = CFGetRetainCount(widget);
91 wxCFRelease(widget);
92 if (count > 1)
93 // Most plug-ins should come here, but x42-limiter will not!
94 wxCFRelease(widget);
95 }
96 }
97#else
98 mNativeWin = nullptr;
99#endif
100}
wxWindowPtr< NativeWindow > mNativeWin
Definition: LV2Validator.h:136
SuilInstancePtr mSuilInstance
Definition: LV2Validator.h:135

References mJustLeakMemory, mNativeWin, and mSuilInstance.

Referenced by LV2Validator::Disconnect(), and ~UI().

Here is the caller graph for this function:

Member Data Documentation

◆ mJustLeakMemory

bool LV2Validator::UI::mJustLeakMemory { false }

Definition at line 138 of file LV2Validator.h.

Referenced by Destroy().

◆ mNativeWin

wxWindowPtr<NativeWindow> LV2Validator::UI::mNativeWin {}

◆ mSuilInstance

SuilInstancePtr LV2Validator::UI::mSuilInstance

The documentation for this struct was generated from the following files: