MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / Dispose

Method Dispose

source/script_gui.cpp:2222–2264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2220
2221
2222void GuiType::Dispose()
2223// Cleans up resources managed separately to the window. This is separate from Destroy()
2224// for maintainability; i.e. to ensure resources are freed even if the window had not been
2225// successfully created.
2226{
2227 if (mDisposed)
2228 return;
2229 mDisposed = true;
2230
2231 if (mBackgroundBrushWin)
2232 DeleteObject(mBackgroundBrushWin);
2233 if (mHdrop)
2234 DragFinish(mHdrop);
2235
2236 // A partially constructed Gui can't have a non-zero mControlCount, but it seems more
2237 // appropriate to do this here than in Destroy():
2238 for (GuiIndexType u = 0; u < mControlCount; ++u)
2239 {
2240 mControl[u]->Dispose();
2241 mControl[u]->Release(); // Release() vs delete because the script may still have references to it.
2242 }
2243 // The following has been confirmed necessary to prevent the script from crashing if
2244 // the controls are being enumerated (e.g. by GuiTypeEnum) when the Gui is destroyed:
2245 mControlCount = 0;
2246
2247 if (mMenu)
2248 mMenu->Release();
2249
2250 mEvents.Dispose();
2251 if (mEventSink && this != mEventSink)
2252 mEventSink->Release();
2253
2254 if (mIconEligibleForDestruction && mIconEligibleForDestruction != g_script.mCustomIcon) // v1.0.37.07.
2255 DestroyIconsIfUnused(mIconEligibleForDestruction, mIconEligibleForDestructionSmall);
2256
2257 // For simplicity and performance, any fonts used *solely* by a destroyed window are destroyed
2258 // only when the program terminates. Another reason for this is that sometimes a destroyed window
2259 // is soon recreated to use the same fonts it did before.
2260
2261 RemoveAccelerators();
2262 free(mControl); // Free the control array, which was previously malloc'd.
2263 free(mName);
2264}
2265
2266
2267void GuiControlType::Dispose()

Callers

nothing calls this directly

Calls 1

ReleaseMethod · 0.45

Tested by

no test coverage detected