# HG changeset patch # User Santeri Piippo # Date 1369355649 -10800 # Node ID 6b2cc2d82ba62e0ad7331920f964227f9b0d3b5a # Parent 4431371f3ffe6a185e8c4488535033b136d9c37f Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway diff -r 4431371f3ffe -r 6b2cc2d82ba6 src/common.h --- a/src/common.h Fri May 24 03:22:11 2013 +0300 +++ b/src/common.h Fri May 24 03:34:09 2013 +0300 @@ -29,6 +29,9 @@ #include #include #include +#include +#include + #include "string.h" #include "config.h" #include "types.h" @@ -106,22 +109,15 @@ #define THREAD_PROPERTY(T, GET, SET) \ private: \ T m_##GET; \ - bool m_threadLock_##GET; \ + QMutex m_threadLock_##GET; \ public: \ - const T& GET () const { \ - while (m_threadLock_##GET) \ - ; \ - return m_##GET; \ - } \ + const T& GET () const { return m_##GET; } \ void callback_##SET (); \ void SET (T val) { \ - while (m_threadLock_##GET) \ - ; \ - \ - m_threadLock_##GET = true; \ + m_threadLock_##GET.lock (); \ m_##GET = val; \ callback_##SET (); \ - m_threadLock_##GET = false; \ + m_threadLock_##GET.unlock (); \ } #ifdef null diff -r 4431371f3ffe -r 6b2cc2d82ba6 src/dialogs.cpp --- a/src/dialogs.cpp Fri May 24 03:22:11 2013 +0300 +++ b/src/dialogs.cpp Fri May 24 03:34:09 2013 +0300 @@ -480,7 +480,7 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -OpenFileDialog::OpenFileDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { +OpenProgressDialog::OpenProgressDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { progressBar = new QProgressBar; progressText = new QLabel; setNumLines (0); @@ -496,17 +496,17 @@ layout->addWidget (dbb_buttons); } -void OpenFileDialog::callback_setNumLines () { +void OpenProgressDialog::callback_setNumLines () { progressBar->setRange (0, numLines ()); updateValues (); } -void OpenFileDialog::updateValues () { +void OpenProgressDialog::updateValues () { progressBar->setValue (progress ()); - progressText->setText (fmt ("%s: %lu/%lu lines parsed", fileName ().c (), progress (), numLines ())); + progressText->setText (fmt ("%lu/%lu lines parsed", progress (), numLines ())); } -void OpenFileDialog::updateProgress (int progress) { +void OpenProgressDialog::updateProgress (int progress) { m_progress = progress; updateValues (); } \ No newline at end of file diff -r 4431371f3ffe -r 6b2cc2d82ba6 src/dialogs.h --- a/src/dialogs.h Fri May 24 03:22:11 2013 +0300 +++ b/src/dialogs.h Fri May 24 03:34:09 2013 +0300 @@ -156,14 +156,13 @@ }; // ============================================================================= -class OpenFileDialog : public QDialog { +class OpenProgressDialog : public QDialog { Q_OBJECT READ_PROPERTY (ulong, progress) CALLBACK_PROPERTY (ulong, numLines, setNumLines) - PROPERTY (str, fileName, setFileName) public: - explicit OpenFileDialog (QWidget* parent = null, Qt::WindowFlags f = 0); + explicit OpenProgressDialog (QWidget* parent = null, Qt::WindowFlags f = 0); public slots: void updateProgress (int progress); diff -r 4431371f3ffe -r 6b2cc2d82ba6 src/file.cpp --- a/src/file.cpp Fri May 24 03:22:11 2013 +0300 +++ b/src/file.cpp Fri May 24 03:34:09 2013 +0300 @@ -270,8 +270,7 @@ loaderThread->start (); // Now create a progress dialog for the operation - OpenFileDialog* dlg = new OpenFileDialog (g_win); - dlg->setFileName ("???"); + OpenProgressDialog* dlg = new OpenProgressDialog (g_win); dlg->setNumLines (numLines); // Connect the loader in so we can actually show updates diff -r 4431371f3ffe -r 6b2cc2d82ba6 src/file.h --- a/src/file.h Fri May 24 03:22:11 2013 +0300 +++ b/src/file.h Fri May 24 03:34:09 2013 +0300 @@ -23,7 +23,7 @@ #include "ldtypes.h" #include -class OpenFileDialog; +class OpenProgressDialog; namespace LDPaths { void initPaths (); bool tryConfigure (str path);