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

#include <LV2Editor.h>

Public Member Functions

void Destroy ()
 
 ~UI ()
 

Public Attributes

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

Detailed Description

Definition at line 134 of file LV2Editor.h.

Constructor & Destructor Documentation

◆ ~UI()

LV2Editor::UI::~UI ( )
inline

Definition at line 136 of file LV2Editor.h.

136{ Destroy(); }
void Destroy()
Definition: LV2Editor.cpp:52

References Destroy().

Here is the call graph for this function:

Member Function Documentation

◆ Destroy()

void LV2Editor::UI::Destroy ( )

Definition at line 52 of file LV2Editor.cpp.

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

References mJustLeakMemory, mNativeWin, and mSuilInstance.

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

Here is the caller graph for this function:

Member Data Documentation

◆ mJustLeakMemory

bool LV2Editor::UI::mJustLeakMemory { false }

Definition at line 140 of file LV2Editor.h.

Referenced by Destroy().

◆ mNativeWin

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

◆ mSuilInstance

SuilInstancePtr LV2Editor::UI::mSuilInstance

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