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
|
||||
|
||||
#include <finder.h>
|
||||
#include <list.h>
|
||||
#include <locator.h>
|
||||
#include <memory.h>
|
||||
#include <menu.h>
|
||||
|
@ -70,7 +71,7 @@ void InstallMenuItem(void) {
|
|||
/* .itemTitleRef = */ (Long)&menuTitle
|
||||
};
|
||||
|
||||
tellFinderAddToExtrasOut dataOutRec;
|
||||
tellFinderAddToExtrasOut dataOutRec = {0};
|
||||
|
||||
SendRequest(tellFinderAddToExtras, sendToName|stopAfterOne,
|
||||
(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) {
|
||||
CloseBrowserWindow();
|
||||
|
||||
RemoveMenuItem();
|
||||
AcceptRequests(NULL, myUserID, NULL);
|
||||
ResourceShutDown();
|
||||
|
||||
/* TODO remove menu item, other cleanup? */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -103,6 +116,10 @@ static pascal Word requestProc(Word reqCode, Long dataIn, void *dataOut) {
|
|||
InstallMenuItem();
|
||||
break;
|
||||
|
||||
case finderSaysGoodbye:
|
||||
RemoveMenuItem();
|
||||
break;
|
||||
|
||||
case finderSaysExtrasChosen:
|
||||
if ((dataIn & 0x0000FFFF) == menuItemID) {
|
||||
ShowBrowserWindow();
|
||||
|
@ -158,5 +175,10 @@ int main(void) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Check for List Manager, in case future Finder doesn't start it. */
|
||||
if (!ListStatus() || toolerror()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
AcceptRequests(diskbrowserRequestName, myUserID, &requestProc);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue