I've run into a problem trying to check for an additional (non-MUI) signal in my MUI event handling code, which is causing various crashes whatever I try. This is complicated by the fact that I have to kludge my event code a bit, as the MUI stuff is unavoidably handled in a separate procedure that cannot be modified.
If I simplify my code down to it's essence, and convert it to C (apologies in advance for any conversion errors!) the follow is the original MUI event code which WORKS:
sigs = 0;
while (TRUE) {
//the following is in a separate procedure
if (sigs) sigs = IExec->Wait(sigs);
IIntuition->IDoMethod(object, MUIM_Application_NewInput, &sigs);
//handle MUI event here
}
I then kludged it a little, such that I can Wait outside of the procedure, and then call the MUI event handling procedure, and this also APPEARS to work:
sigs = 0;
while (TRUE) {
if (sigs) sigs = IExec->Wait(sigs);
IExec->SetSignal(-1, sigs);
//the following is in a separate procedure
if (sigs) sigs = IExec->Wait(sigs);
IIntuition->IDoMethod(object, MUIM_Application_NewInput, &sigs);
//handle MUI event here
}
Finally I allocate a non-MUI signal, and get my code to wait for it as well as the MUI signal:
anotherSignalNum = IExec->AllocSignal(-1);
anotherSignal = 1 << anotherSignalNum;
sigs = 0;
while (TRUE) {
sigs = sigs | anotherSignal;
if (sigs) sigs = IExec->Wait(sigs);
IExec->SetSignal(-1, sigs /*& ~anotherSignal*/);
//handle AnotherSignal event here
//the following is in a separate procedure
if (sigs) sigs = IExec->Wait(sigs);
IIntuition->IDoMethod(object, MUIM_Application_NewInput, &sigs);
//handle MUI event here
}
This code SORT OF works, but it tends to crash
.
If I make it "more correct", by uncommenting the /**/ bit then MUI simply stops responding. (EDIT: That happens even if the second Wait() is only executed when "sigs & ~anotherSignal" is non-zero.) The only possible explanation I can think of is that MUI is using the signal that *I* allocated myself (anotherSignal) - but that should not be possible.
Edited by ChrisH on 2011/8/22 21:32:27
Edited by ChrisH on 2011/8/22 21:38:10
Edited by ChrisH on 2011/8/22 21:58:42
Edited by ChrisH on 2011/8/23 14:47:27