LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange EVENT_DISCARD Behaviour

CVI 2019. 

 

I have a couple pretty large apps that have suddenly started acting odd under 2019 in debug on Win10.  When I quit the app EVENT_DISCARD is issued to every Callback function.  Not just once, but infinitely.  I always have to click the red stop button a couple extra times to get the app to actually quit.  I put a case EVENT_DISCARD: in one of the callbacks, with a breakpoint, so I could see this point reached over and over.  At some point a stack overflows or something, because the app goes belly-up quitting at some unknown location.

 

This does not seem to happen in Windows 7.

 

Anyone ever see this?  Is there some setting in the IDE I'm missing to prevent this?

 

 

0 Kudos
Message 1 of 9
(3,365 Views)

I have just installed 2019, so I have not been working yet with my many old programs. Do you do anything in your EVENT_DISCARD cases ? If not, why do you have a case ? And what if you return 1 to swallow the event ?

0 Kudos
Message 2 of 9
(3,196 Views)

After a little investigation of why the app never actually quite, I found the EVENT_DISCARD thing.  Added a case to one callback, just to trap it and see that every callback was issued the event thousands of times, until something just failed.  I will try the return 1; but the library .h says the event is not swallowable.

0 Kudos
Message 3 of 9
(3,089 Views)

return 1; does nothing.  EVENT_DISCARD continues to be issued thousands of times.

0 Kudos
Message 4 of 9
(3,081 Views)

I still need help with this. 

 

Has anybody seen behavior like this?

0 Kudos
Message 5 of 9
(2,906 Views)

Where do you call QuitUserInterface() ?

0 Kudos
Message 6 of 9
(2,891 Views)

As I mentioned in the first post, this does not happen in Win7, only Win10.

 

I think this is very standard.

At the end of Main:

	RunUserInterface ();
QuitUserInterface();
DiscardPanel (panelHandle);
return 0;
}

At the end of QuitCallback:

	Sleep(500);
QuitUserInterface (0);
break;
}
return 0;
}

 Perhaps it is routine to send EVENT_DISCARD to every callback during the execution of DiscardPanel(), but it never stops.  It just cycles through all callbacks forever, sending EVENT_DISCARD.

0 Kudos
Message 7 of 9
(2,883 Views)

You QuitUserInterface should be in the callback of your top panel(s) in reply to EVENT_CLOSE

0 Kudos
Message 8 of 9
(2,879 Views)

I have used exactly the method specified in the RunUserInterface function panel, shown below.  And as outlined in the code fragments posted previously.

 

int main (int argc, char *argv[])
{
int status;
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "sample.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
status = RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}

/* additional callback functions here */

int CVICALLBACK QuitCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}

0 Kudos
Message 9 of 9
(2,873 Views)