LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic menus make labview crash

Hi!
I have a question regarding dynamic menus in labview.
I have a application that starts with a default set of menus which are created with a menubar and a couple of inserted standard items.
But I also have a feature that updates this menubar with new item depending on current state of the application.
When I update the menu with my new items i first make a "delete menu items" on current menubar and the inserts all items again with the modifications.
But what I found out was that if I have a menu open (i.e. if i have clicked on the "File" item once in the menu) and the program decides to update the menu labview crashes.
I suppose Labview deletes the menu while it's actually open !?!?  Labview crashes with an application error saying referenced memory at 0x000000. The memory could not be read.
I've tried to find a solution to disable menus or simulate a "escape" key just before i do delete menu items...but haven't succeded yet.
This problem doesn't occur normally...but it happened 4-6 times in my real application..... don't want this to happen at all.
Is there anyone which experienced the same problem and might have a nice solutions to this problem ?
 
Best Regards
Marcus
0 Kudos
Message 1 of 9
(3,873 Views)
Hello Marcus!
 
I really would appreciate if you could upload an example that showcases what you want to achieve and how you have implemented it. If we have that we might be able to give you some suggestions on how to proceed!
 
Regards,
Jimmie A.
Applications Engineer, National Instruments
Regards,
Jimmie Adolph
Systems Engineering Manager, National Instruments Northern European Region

0 Kudos
Message 2 of 9
(3,797 Views)
Hi!
I've attached an example from labview 7.1.1. The vi is only an example of what happens in my real application. In this example the menu uppdates every 2 seconds, but in my real app. it updates when a new menu need to appear. So if you run the example and opens a menu a without selecting anything and wait 2 secs.... the you will get the crash.
 
Best Regards
Marcus
0 Kudos
Message 3 of 9
(3,779 Views)
Hi,


Every time the event structure has a time out (every 2 sec in the example), the entire menu is rebuild. You should put the menu creation outside the while loop (and in a sub vi).


BTW1: Labview still shouldn't crash, even if you do it like in the example. It's a bug.


BTW2: The error handling might not do what you expect. The for loop that sets the shortcut keys only returns the last error (which is no error), while previous results have errors. Use a shift register instead of normal terminal, or build an array of errors and merge them.


Regards,


Wiebe.
"walle" <x@no.email> wrote in message news:1140594034984-328423@exchange.ni.com...
Hi!
I've attached an example from labview 7.1.1. The vi is only an example of what happens in my real application. In this example the menu uppdates every 2 seconds, but in my real app. it updates when a new menu need to appear. So if you run the example and opens a menu a&nbsp;without selecting anything and wait 2 secs.... the you will get the crash.
&nbsp;
Best Regards
Marcus



Dynamic Insert Demo.vi:
http://forums.ni.com/attachments/ni/170/169073/1/Dynamic Insert Demo.vi
0 Kudos
Message 4 of 9
(3,769 Views)

But the intention with this code is to rebuild the whole menu... !! Dynamic rebuild of menu !

So the code is made just as I want ! The application adds new menu items depending on how the user acts and what state the application is in.

The error occurs because the menu is open when "delete menu" deletes all items ...

0 Kudos
Message 5 of 9
(3,765 Views)
Hi,
 
Sorry about that. LabVIEW does crash if you (try to) delete an active menu. The event structure is not even needed.
 
The only way around this (it took me a while to find a way), is to make a window popup just before you delete the menu. The active menu selection is deleted.
 
So I made a new vi, with a random output (or use error in/error out to synchronise). I set the window properties to Show front panel when called, Close afterwards.., Modal. In this VI, I wired the errors, and put a Panel Bounds property with 0,0,1,1 in it (so it won't flash).
 
With this vi it is still theoretically possible to activate the menu just after the popup. So I put the menu delete inside the subvi. A nice subvi "Safe Menu Delete Items.vi" is born.
 
I hope it is usefull to you.
 
Regards,
 
Wiebe.
0 Kudos
Message 6 of 9
(3,755 Views)
Whee, that actually worked! Thanks for the tip!
This is a nice workaround for the problem!
 
Thanks!
/Marcus
0 Kudos
Message 7 of 9
(3,754 Views)
This problem was fixed in 8.0.  CAR 39G1DTO9.  There is a slight behavior change, however, because LabVIEW can't change the actual menu contents while it's being displayed.  So, the "Insert Menu Items" and the "Delete Menu Items" functions will now return an error (Error 1404) if LabVIEW tried to modify a menu while it was being displayed.  We felt this was the right thing to do since the operation was going to fail, so we felt we needed to let the program know that it failed so it can retry it later.  Otherwise, the program will assume that the menu is in the right state, when it won't be.
 
Robbie
0 Kudos
Message 8 of 9
(3,717 Views)
So my nice "Safe Delete Menu Items.vi" will still be usefull in LV8!


Regards,


Wiebe.


"RobbieG" <x@no.email> wrote in message news:1141427453540-333528@exchange.ni.com...
This problem was fixed in 8.0.&nbsp;&nbsp;CAR 39G1DTO9.&nbsp; There is a slight behavior change, however, because&nbsp;LabVIEW can't&nbsp;change the actual menu contents while it's being displayed.&nbsp; So, the "Insert Menu Items" and the "Delete Menu Items" functions will now return an error (Error 1404) if LabVIEW tried to modify a menu while it was being displayed.&nbsp; We felt this was the right thing to do since the operation was going to fail, so we felt we needed to let the program know that it failed so it can retry it later.&nbsp; Otherwise, the program will assume that the menu is in the right state, when it won't be.
&nbsp;
Robbie
Message 9 of 9
(3,709 Views)