<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>ok, understood that piece of code. It was correct.</DIV>
<DIV> </DIV>
<DIV>The reason multiple tray icons appear is due to an error in mActive field of VBoxTrayIcon, needs to be initialized to false inside VBoxTrayIcon constructor</DIV>
<DIV> </DIV><FONT size=2>
<DIV>VBoxTrayIcon::VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel)</DIV>
<DIV>{</DIV>
<DIV>mParent = aParent;</DIV>
<DIV>mVMModel = aVMModel;</DIV>
<DIV> </DIV>
<DIV><STRONG>mActive = </STRONG></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2><STRONG>false</STRONG></FONT></FONT><FONT size=2><STRONG>;  <====== NEED TO ADD THIS </STRONG></DIV>
<DIV></FONT> </DIV>
<DIV>}</DIV>
<DIV><BR><BR>--- On <B>Fri, 7/30/10, Huihong Luo <I><huisinro@yahoo.com></I></B> wrote:<BR></DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid"><BR>From: Huihong Luo <huisinro@yahoo.com><BR>Subject: [vbox-dev] Help me understanding the following code segment (VBoxGlobal::trayIconInstall())<BR>To: vbox-dev@virtualbox.org<BR>Date: Friday, July 30, 2010, 10:09 AM<BR><BR>
<DIV id=yiv32464868>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=top>
<DIV>I am having trouble understanding the following code about mVBox.SetExtraData  to "0". How does this check whether tray icon died? shouldn't <FONT color=#0000ff>if</FONT><FONT size=2> (mVBox.isOk()) be <FONT color=#0000ff>if</FONT><FONT size=2> ( ! mVBox.isOk()) ? </FONT></FONT></DIV>
<DIV> </DIV>
<DIV>This cleans up the tray winid, and will make TrayIcon not singleton.</DIV>
<DIV> </DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>bool</FONT></FONT><FONT size=2> VBoxGlobal::trayIconInstall()</DIV>
<DIV>{</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2> rc = 0;</DIV>
<DIV>QString strTrayWinID = mVBox.GetExtraData (VBoxDefs::GUI_TrayIconWinID);</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>false</FONT></FONT><FONT size=2> == strTrayWinID.isEmpty())</DIV>
<DIV>{</DIV>
<DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>/* Check if current tray icon is alive by writing some bogus value. */</DIV></FONT></FONT><FONT size=2>
<DIV>mVBox.SetExtraData (VBoxDefs::GUI_TrayIconWinID, </FONT><FONT color=#800000 size=2><FONT color=#800000 size=2>"0"</FONT></FONT><FONT size=2>);</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (mVBox.isOk())</DIV>
<DIV>{</DIV>
<DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>/* Current tray icon died - clean up. */</DIV></FONT></FONT><FONT size=2>
<DIV>mVBox.SetExtraData (VBoxDefs::GUI_TrayIconWinID, NULL);</DIV>
<DIV>strTrayWinID.clear();</DIV>
<DIV>}</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV> </DIV></FONT></TD></TR></TBODY></TABLE></DIV><BR>-----Inline Attachment Follows-----<BR><BR>
<DIV class=plainMail>_______________________________________________<BR>vbox-dev mailing list<BR><A href="http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org" ymailto="mailto:vbox-dev@virtualbox.org">vbox-dev@virtualbox.org</A><BR><A href="http://vbox.innotek.de/mailman/listinfo/vbox-dev" target=_blank>http://vbox.innotek.de/mailman/listinfo/vbox-dev</A><BR></DIV></BLOCKQUOTE></td></tr></table>