Extra guards during destroy

This commit is contained in:
Lea Anthony
2021-01-01 12:37:16 +11:00
parent 33a27b06a6
commit 5ca57e446a
3 changed files with 69 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
// defaultdialogicons.c
// defaultdialogicons_darwin.c
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL.
// This file was auto-generated. DO NOT MODIFY.

View File

@@ -889,6 +889,10 @@ int releaseNSObject(void *const context, struct hashmap_element_s *const e) {
void destroyMenu(struct Application *app) {
if( app->menuAsJSON == NULL ) {
return;
}
// Free menu item hashmap
hashmap_destroy(&menuItemMapForApplicationMenu);
@@ -908,7 +912,7 @@ void destroyMenu(struct Application *app) {
app->processedMenu = NULL;
}
// Remove the current Menu
// Remove the menu if we have one
id menubar = msg(msg(c("NSApplication"), s("sharedApplication")), s("mainMenu"));
Debug(app, "Destroying menubar: %p", menubar);
msg(menubar, s("release"));
@@ -966,6 +970,10 @@ void freeDialogIconCache(struct Application *app) {
void destroyTray(struct Application *app) {
if( app->trayMenuAsJSON == NULL ) {
return;
}
// Release the tray cache images
if( hashmap_num_entries(&trayIconCache) > 0 ) {
if (0!=hashmap_iterate_pairs(&trayIconCache, releaseNSObject, NULL)) {

View File

@@ -0,0 +1,59 @@
# Assets Directory
The assets directory is used to house all the assets of your application.
The structure is:
* dialog - Icons for dialogs
* tray - Icons for the system tray
* custom - A place for assets you wish to bundle in the application
* mac - MacOS specific files
* linux - Linux specific files
* windows - Windows specific files
## Dialog Icons
Place any PNG file in this directory to be able to use them in message dialogs.
The files should have names in the following format: `name[-(light|dark)][2x].png`
Examples:
* `mypic.png` - Standard definition icon with ID `mypic`
* `mypic-light.png` - Standard definition icon with ID `mypic`, used when system theme is light
* `mypic-dark.png` - Standard definition icon with ID `mypic`, used when system theme is dark
* `mypic2x.png` - High definition icon with ID `mypic`
* `mypic-light2x.png` - High definition icon with ID `mypic`, used when system theme is light
* `mypic-dark2x.png` - High definition icon with ID `mypic`, used when system theme is dark
### Order of preference
Icons are selected with the following order of preference:
For High Definition displays:
* name-(theme)2x.png
* name2x.png
* name-(theme).png
* name.png
For Standard Definition displays:
* name-(theme).png
* name.png
## Tray
Place any PNG file in this directory to be able to use them as tray icons.
The name of the filename will be the ID to reference the image.
Example:
* `mypic.png` - May be referenced using `runtime.Tray.SetIcon("mypic")`
## Custom
Any file in this directory will be embedded into the app using the Wails asset bundler.
Assets can be retrieved using the following methods:
* `wails.Assets().Read(filename string) ([]byte, error)`
* `wails.Assets().String(filename string) (string, error)`
The filename should include the path to the file relative to the `custom` directory.