mirror of
https://github.com/sheumann/DiskBrowser.git
synced 2024-11-25 02:32:44 +00:00
Improved clean-up code.
This shouldn't ordinarily make any difference, but it may help to ensure things are correctly handled in some corner cases.
This commit is contained in:
parent
36e9f1ab0d
commit
e2b2305b10
@ -5,6 +5,7 @@
|
|||||||
#pragma rtl
|
#pragma rtl
|
||||||
|
|
||||||
#include <finder.h>
|
#include <finder.h>
|
||||||
|
#include <list.h>
|
||||||
#include <locator.h>
|
#include <locator.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <menu.h>
|
#include <menu.h>
|
||||||
@ -70,7 +71,7 @@ void InstallMenuItem(void) {
|
|||||||
/* .itemTitleRef = */ (Long)&menuTitle
|
/* .itemTitleRef = */ (Long)&menuTitle
|
||||||
};
|
};
|
||||||
|
|
||||||
tellFinderAddToExtrasOut dataOutRec;
|
tellFinderAddToExtrasOut dataOutRec = {0};
|
||||||
|
|
||||||
SendRequest(tellFinderAddToExtras, sendToName|stopAfterOne,
|
SendRequest(tellFinderAddToExtras, sendToName|stopAfterOne,
|
||||||
(Long)NAME_OF_FINDER,
|
(Long)NAME_OF_FINDER,
|
||||||
@ -84,12 +85,24 @@ void InstallMenuItem(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoveMenuItem(void) {
|
||||||
|
tellFinderRemoveFromExtrasOut dataOutRec = {0};
|
||||||
|
|
||||||
|
if (menuItemID == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SendRequest(tellFinderRemoveFromExtras, sendToName|stopAfterOne,
|
||||||
|
(Long)NAME_OF_FINDER,
|
||||||
|
(Long)menuItemID,
|
||||||
|
(Ptr)&dataOutRec);
|
||||||
|
menuItemID = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void DoGoAway(void) {
|
void DoGoAway(void) {
|
||||||
CloseBrowserWindow();
|
CloseBrowserWindow();
|
||||||
|
RemoveMenuItem();
|
||||||
|
AcceptRequests(NULL, myUserID, NULL);
|
||||||
ResourceShutDown();
|
ResourceShutDown();
|
||||||
|
|
||||||
/* TODO remove menu item, other cleanup? */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -103,6 +116,10 @@ static pascal Word requestProc(Word reqCode, Long dataIn, void *dataOut) {
|
|||||||
InstallMenuItem();
|
InstallMenuItem();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case finderSaysGoodbye:
|
||||||
|
RemoveMenuItem();
|
||||||
|
break;
|
||||||
|
|
||||||
case finderSaysExtrasChosen:
|
case finderSaysExtrasChosen:
|
||||||
if ((dataIn & 0x0000FFFF) == menuItemID) {
|
if ((dataIn & 0x0000FFFF) == menuItemID) {
|
||||||
ShowBrowserWindow();
|
ShowBrowserWindow();
|
||||||
@ -158,5 +175,10 @@ int main(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for List Manager, in case future Finder doesn't start it. */
|
||||||
|
if (!ListStatus() || toolerror()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
AcceptRequests(diskbrowserRequestName, myUserID, &requestProc);
|
AcceptRequests(diskbrowserRequestName, myUserID, &requestProc);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user