OSDN Git Service

Better workaround for the previous commit.
authorlordmulder <mulder2@gmx.de>
Fri, 23 Mar 2012 00:29:50 +0000 (01:29 +0100)
committerlordmulder <mulder2@gmx.de>
Fri, 23 Mar 2012 00:29:50 +0000 (01:29 +0100)
src/Config.h
src/Dialog_SplashScreen.cpp
src/Dialog_SplashScreen.h

index c1f22fb..bfa71ac 100644 (file)
@@ -30,7 +30,7 @@
 #define VER_LAMEXP_MINOR_LO                                    4
 #define VER_LAMEXP_TYPE                                                Beta
 #define VER_LAMEXP_PATCH                                       7
-#define VER_LAMEXP_BUILD                                       914
+#define VER_LAMEXP_BUILD                                       915
 
 ///////////////////////////////////////////////////////////////////////////////
 // Tool versions (minimum expected versions!)
index d68df63..3166244 100644 (file)
@@ -38,7 +38,8 @@
 ////////////////////////////////////////////////////////////
 
 SplashScreen::SplashScreen(QWidget *parent)
-       : QFrame(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint)
+:
+       QFrame(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint)
 {
        //Init the dialog, from the .ui file
        setupUi(this);
@@ -118,16 +119,13 @@ void SplashScreen::showSplash(QThread *thread)
        timer->start(30720);
 
        //Loop while thread is still running
-       while(thread->isRunning())
+       bool bStillRunning = threadStillRunning(thread);
+       while(bStillRunning)
        {
                loop->exec();
-               if(thread->isRunning())
+               if(bStillRunning = threadStillRunning(thread))
                {
-                       QThread::yieldCurrentThread();
-                       if(thread->isRunning())
-                       {
-                               qWarning("Potential deadlock in initialization thread!");
-                       }
+                       qWarning("Potential deadlock in initialization thread!");
                }
        }
 
@@ -179,3 +177,21 @@ bool SplashScreen::winEvent(MSG *message, long *result)
 {
        return WinSevenTaskbar::handleWinEvent(message, result);
 }
+
+////////////////////////////////////////////////////////////
+// HELPER FUNCTIONS
+////////////////////////////////////////////////////////////
+
+bool SplashScreen::threadStillRunning(const QThread *thread)
+{
+       for(int i = 0; i < 128; i++)
+       {
+               if(!(thread->isRunning()))
+               {
+                       return false;
+               }
+               QThread::yieldCurrentThread();
+       }
+
+       return thread->isRunning();
+}
index 8c3df28..f30b38a 100644 (file)
@@ -41,6 +41,8 @@ private:
        QMovie *m_working;
        bool m_canClose;
 
+       static inline bool threadStillRunning(const QThread *thread);
+
 protected:
        void keyPressEvent(QKeyEvent *event);
        void keyReleaseEvent(QKeyEvent *event);