-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
this patch makes the errors/warnings message box popups that are rootless
to popup only one at the time, instead of having lots of popups.
the solution is a queue for orphan messages. if some one is interested in
it, check the code. is my first c++ class. comments are apresiated.
how to test it? I moved the history directory to another location and
from another icq i started to send messages.
Related bug reports:
#563923
#546954
#526141
Regards,
-juan
-----BEGIN PGP SIGNATURE-----
iD8DBQE9QEFSUMlRieHkprgRAhG3AJ9L6oNFhM6kswRJwx1LDkUQ3oclyQCgthsM
FvVvA2lRv1CA93pqSktI4tY=
=ZEJh
-----END PGP SIGNATURE-----
Index: plugins/qt-gui/src/ewidgets.cpp
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/ewidgets.cpp,v
retrieving revision 1.60
diff -u -d -p -r1.60 ewidgets.cpp
--- plugins/qt-gui/src/ewidgets.cpp 22 Jul 2002 21:02:06 -0000 1.60
+++ plugins/qt-gui/src/ewidgets.cpp 25 Jul 2002 18:08:22 -0000
@@ -26,6 +26,9 @@
#include "ewidgets.h"
#include "usercodec.h"
+#define QT_THREAD_SUPPORT
+#include <qmutex.h>
+
bool QueryUser(QWidget *q, QString szQuery, QString szBtn1, QString szBtn2)
{
#ifdef USE_KDE
@@ -46,19 +49,19 @@ int QueryUser(QWidget *q, QString szQuer
}
-void InformUser(QWidget *q, QString sz)
+static void informUser(QWidget *q, QString &sz)
{
- //(void) new CLicqMessageBox(szInfo, QMessageBox::Information, q);
#ifdef USE_KDE
KMessageBox::information(q, sz, QMessageBox::tr("Licq Information"), QString::null, false);
#else
- QMessageBox::information(q, QMessageBox::tr("Licq Information"), sz, QMessageBox::Ok | QMessageBox::Default);
+ QMessageBox::information(q, QMessageBox::tr("Licq Information"), sz, QMessageBox::Ok | QMessageBox::Default);
#endif
+
}
-void WarnUser(QWidget *q, QString sz)
+static void warnUser(QWidget *q, QString &sz)
{
- //(void) new CLicqMessageBox(szInfo, QMessageBox::Warning, q);
+
#ifdef USE_KDE
KMessageBox::sorry(q, sz, QMessageBox::tr("Licq Warning"), false);
#else
@@ -66,14 +69,121 @@ void WarnUser(QWidget *q, QString sz)
#endif
}
-void CriticalUser(QWidget *q, QString sz)
+static void criticalUser(QWidget *q, QString &sz)
{
- //(void) new CLicqMessageBox(szInfo, QMessageBox::Critical, q);
+
#ifdef USE_KDE
- KMessageBox::error(q, sz, QMessageBox::tr("Licq Error"), false);
+KMessageBox::error(q, sz, QMessageBox::tr("Licq Error"), false);
#else
QMessageBox::warning(q, QMessageBox::tr("Licq Error"), sz, QMessageBox::Ok | QMessageBox::Default, 0);
#endif
+}
+
+class OrphanMsgManager
+{
+public:
+ enum type
+ { OM_INFORM,
+ OM_WARN,
+ OM_CRITICAL
+ };
+ OrphanMsgManager( void )
+ {
+ bUsed = false;
+ }
+ void AddMessage( enum type t, QString &sz )
+ {
+ struct msg m;
+
+ m.sz = sz;
+ m.nType = t;
+
+ mutex.lock();
+ OrphanMsgList.push_back( m );
+ mutex.unlock();
+ }
+ void ShowNext( void )
+ {
+ struct msg m;
+
+ mutexShow.lock();
+ if( bUsed )
+ { mutexShow.unlock();
+ return;
+ }
+ else
+ bUsed = true;
+ mutexShow.unlock();
+
+
+ mutex.lock();
+ while( !OrphanMsgList.empty() )
+ {
+ m = OrphanMsgList.front();
+ OrphanMsgList.pop_front();
+ mutex.unlock();
+
+ switch( m.nType )
+ {
+ case OM_INFORM:
+ informUser(0,m.sz);
+ break;
+ case OM_WARN:
+ warnUser(0,m.sz);
+ break;
+ case OM_CRITICAL:
+ criticalUser(0,m.sz);
+ break;
+ default:
+ assert(0);
+ }
+ mutex.lock();
+ }
+ mutex.unlock();
+ bUsed = false;
+ }
+private:
+ struct msg
+ { QString sz;
+ enum type nType;
+ };
+ std::list<struct msg> OrphanMsgList;
+ QMutex mutex;
+ QMutex mutexShow;
+ bool bUsed;
+};
+
+static class OrphanMsgManager OrphanMsgMng;
+
+void InformUser(QWidget *q, QString sz)
+{
+ if( q == 0 )
+ { OrphanMsgMng.AddMessage(OrphanMsgManager::OM_INFORM,sz);
+ OrphanMsgMng.ShowNext();
+ }
+ else
+ informUser(q,sz);
+}
+
+void WarnUser(QWidget *q, QString sz)
+{
+ if( q == 0 )
+ {
+ OrphanMsgMng.AddMessage(OrphanMsgManager::OM_WARN,sz);
+ OrphanMsgMng.ShowNext();
+ }
+ else
+ warnUser(q,sz);
+}
+
+void CriticalUser(QWidget *q, QString sz)
+{
+ if( q == 0 )
+ { OrphanMsgMng.AddMessage(OrphanMsgManager::OM_CRITICAL,sz);
+ OrphanMsgMng.ShowNext();
+ }
+ else
+ warnUser(q,sz);
}
//-----CELabel------------------------------------------------------------------