Fixed silly use of all hidden variable. Update it when a window is destroyed while owning tray icons.
git-svn-id: http://yate.null.ro/svn/yate/trunk@2567 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
ac35c3226c
commit
6e3a28cafc
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
namespace TelEngine {
|
namespace TelEngine {
|
||||||
|
|
||||||
static int s_allHiddenQuit = 1; // Quit on all hidden notification
|
static unsigned int s_allHiddenQuit = 0; // Quit on all hidden notification if this counter is 0
|
||||||
|
|
||||||
// Macro used to get a QT object's name
|
// Macro used to get a QT object's name
|
||||||
// Can't use an inline function: the QByteArray object returned by toUtf8()
|
// Can't use an inline function: the QByteArray object returned by toUtf8()
|
||||||
|
@ -779,6 +779,19 @@ QtWindow::QtWindow(const char* name, const char* description, const char* alias)
|
||||||
|
|
||||||
QtWindow::~QtWindow()
|
QtWindow::~QtWindow()
|
||||||
{
|
{
|
||||||
|
// Update all hidden counter for tray icons owned by this window
|
||||||
|
QList<QSystemTrayIcon*> trayIcons = qFindChildren<QSystemTrayIcon*>(this);
|
||||||
|
if (trayIcons.size() > 0) {
|
||||||
|
if (s_allHiddenQuit >= (unsigned int)trayIcons.size())
|
||||||
|
s_allHiddenQuit -= trayIcons.size();
|
||||||
|
else {
|
||||||
|
Debug(QtDriver::self(),DebugFail,
|
||||||
|
"QtWindow(%s) destroyed with all hidden counter %u greater then tray icons %d [%p]",
|
||||||
|
m_id.c_str(),s_allHiddenQuit,trayIcons.size(),this);
|
||||||
|
s_allHiddenQuit = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save settings
|
// Save settings
|
||||||
if (m_saveOnClose) {
|
if (m_saveOnClose) {
|
||||||
m_maximized = isMaximized();
|
m_maximized = isMaximized();
|
||||||
|
@ -861,9 +874,14 @@ bool QtWindow::setParams(const NamedList& params)
|
||||||
// Delete
|
// Delete
|
||||||
if (ns->null()) {
|
if (ns->null()) {
|
||||||
if (trayIcon) {
|
if (trayIcon) {
|
||||||
delete trayIcon;
|
|
||||||
// Reactivate program termination when the last window was hidden
|
// Reactivate program termination when the last window was hidden
|
||||||
s_allHiddenQuit++;
|
if (s_allHiddenQuit)
|
||||||
|
s_allHiddenQuit--;
|
||||||
|
else
|
||||||
|
Debug(QtDriver::self(),DebugFail,
|
||||||
|
"QtWindow(%s) all hidden counter is 0 while deleting '%s' tray icon [%p]",
|
||||||
|
m_id.c_str(),YQT_OBJECT_NAME(trayIcon),this);
|
||||||
|
delete trayIcon;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -874,14 +892,13 @@ bool QtWindow::setParams(const NamedList& params)
|
||||||
continue;
|
continue;
|
||||||
trayIcon = new QSystemTrayIcon(this);
|
trayIcon = new QSystemTrayIcon(this);
|
||||||
trayIcon->setObjectName(QtClient::setUtf8(ns->name()));
|
trayIcon->setObjectName(QtClient::setUtf8(ns->name()));
|
||||||
if (QtClient::connectObjects(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
QtClient::connectObjects(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
this,SLOT(sysTrayIconAction(QSystemTrayIcon::ActivationReason)))) {
|
this,SLOT(sysTrayIconAction(QSystemTrayIcon::ActivationReason)));
|
||||||
// Deactivate program termination when the last window was hidden
|
// Deactivate program termination when the last window was hidden
|
||||||
s_allHiddenQuit--;
|
s_allHiddenQuit++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ok = true;
|
||||||
// Add dynamic properties on creation
|
// Add dynamic properties on creation
|
||||||
// See
|
|
||||||
if (newObj)
|
if (newObj)
|
||||||
addDynamicProps(trayIcon,*nl);
|
addDynamicProps(trayIcon,*nl);
|
||||||
// Set icon and tooltip
|
// Set icon and tooltip
|
||||||
|
@ -2365,7 +2382,7 @@ void QtClient::unlock()
|
||||||
void QtClient::allHidden()
|
void QtClient::allHidden()
|
||||||
{
|
{
|
||||||
Debug(QtDriver::self(),DebugInfo,"QtClient::allHiden() counter=%d",s_allHiddenQuit);
|
Debug(QtDriver::self(),DebugInfo,"QtClient::allHiden() counter=%d",s_allHiddenQuit);
|
||||||
if (!s_allHiddenQuit)
|
if (s_allHiddenQuit > 0)
|
||||||
return;
|
return;
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue