mirror of
https://github.com/sheumann/DiskBrowser.git
synced 2024-11-28 22:50:23 +00:00
Open up the Finder window for the new disk after it has been mounted.
We have to wait through two cycles of the Finder's event loop before asking for it to be opened. Doing it earlier may cause the Finder to crash, presumably because it hasn't registered that a new disk has been inserted and updated its internal data structures accordingly.
This commit is contained in:
parent
d9186312ce
commit
28e1125207
@ -107,6 +107,10 @@ char *netBuf = NULL;
|
|||||||
|
|
||||||
json_value *json = NULL;
|
json_value *json = NULL;
|
||||||
|
|
||||||
|
int wantToOpenWindow = 0;
|
||||||
|
GSString32 devName;
|
||||||
|
struct tellFinderOpenWindowOut tfowOut;
|
||||||
|
|
||||||
void InstallMenuItem(void) {
|
void InstallMenuItem(void) {
|
||||||
static MenuItemTemplate menuItem = {
|
static MenuItemTemplate menuItem = {
|
||||||
/* .version = */ 0x8000, /* show dividing line */
|
/* .version = */ 0x8000, /* show dividing line */
|
||||||
@ -429,6 +433,12 @@ void MountFile(char *itemID, char *fileName) {
|
|||||||
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
|
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
|
||||||
(Long)&mountURLRec, NULL);
|
(Long)&mountURLRec, NULL);
|
||||||
|
|
||||||
|
if (mountURLRec.result == OPERATION_SUCCESSFUL) {
|
||||||
|
devName.length = snprintf(devName.text, sizeof(devName.text), ".D%u",
|
||||||
|
mountURLRec.devNum);
|
||||||
|
wantToOpenWindow = 2;
|
||||||
|
}
|
||||||
|
|
||||||
free(fileURL);
|
free(fileURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,6 +467,8 @@ void DoMount(void) {
|
|||||||
enum NetDiskError result = 0;
|
enum NetDiskError result = 0;
|
||||||
json_value *filesJSON = NULL;
|
json_value *filesJSON = NULL;
|
||||||
|
|
||||||
|
WaitCursor();
|
||||||
|
|
||||||
if (itemNumber == 0) {
|
if (itemNumber == 0) {
|
||||||
// shouldn't happen
|
// shouldn't happen
|
||||||
result = 1;
|
result = 1;
|
||||||
@ -492,11 +504,13 @@ void DoMount(void) {
|
|||||||
processArray(resultJSON, json_object, processFile);
|
processArray(resultJSON, json_object, processFile);
|
||||||
|
|
||||||
errorReturn:
|
errorReturn:
|
||||||
if (result != 0)
|
|
||||||
ShowErrorAlert(result, mountErrorAlert);
|
|
||||||
if (filesJSON != NULL)
|
if (filesJSON != NULL)
|
||||||
json_value_free(filesJSON);
|
json_value_free(filesJSON);
|
||||||
free(filesURL);
|
free(filesURL);
|
||||||
|
|
||||||
|
InitCursor();
|
||||||
|
if (result != 0)
|
||||||
|
ShowErrorAlert(result, mountErrorAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -674,6 +688,8 @@ void ShowBrowserWindow(void) {
|
|||||||
lastTargetCtlID = 0;
|
lastTargetCtlID = 0;
|
||||||
defaultButtonIsSearch = true;
|
defaultButtonIsSearch = true;
|
||||||
|
|
||||||
|
wantToOpenWindow = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (resourceFileOpened && !windowOpened) {
|
if (resourceFileOpened && !windowOpened) {
|
||||||
CloseResourceFile(resourceFileID);
|
CloseResourceFile(resourceFileID);
|
||||||
@ -709,6 +725,17 @@ static pascal Word requestProc(Word reqCode, Long dataIn, void *dataOut) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case finderSaysIdle:
|
||||||
|
/*
|
||||||
|
* Wait till the Finder has had time to recognize the new disk
|
||||||
|
* before opening the window for it. Otherwise, it may crash.
|
||||||
|
*/
|
||||||
|
if (wantToOpenWindow && --wantToOpenWindow == 0) {
|
||||||
|
SendRequest(tellFinderOpenWindow, sendToName|stopAfterOne,
|
||||||
|
(Long)NAME_OF_FINDER, (Long)&devName, (Ptr)&tfowOut);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case srqGoAway:
|
case srqGoAway:
|
||||||
DoGoAway();
|
DoGoAway();
|
||||||
((srqGoAwayOut*)dataOut)->resultID = myUserID;
|
((srqGoAwayOut*)dataOut)->resultID = myUserID;
|
||||||
|
Loading…
Reference in New Issue
Block a user