# HG changeset patch # User sheepluva # Date 1319564819 -7200 # Node ID 7764cbe4ddd7d6c547e4a68d10b52e2f723e46e2 # Parent 80cd75daf80f62260e54d822f515d9b25d3ad343 remove any thread-safe stuff I introduced since it's not needed as unC0Rr pointed out it's not needed, we are single-threaded (thanks :D) from what I understood this time, Qt is clever enough to sequentialize all events and child destructions instead of spawning threads also some docs/comments diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/hwform.cpp Tue Oct 25 19:46:59 2011 +0200 @@ -455,10 +455,6 @@ void HWForm::OnPageShown(quint8 id, quint8 lastid) { - // with all those signals firing around make sure we don't switch a page - // at the same time in different threads - onPageShownMutex.lock(); - #ifdef USE_XFIRE updateXfire(); #endif @@ -539,8 +535,6 @@ else if (id == ID_PAGE_ROOMSLIST) ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text()); - - onPageShownMutex.unlock(); } void HWForm::GoToPage(int id) diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/hwform.h Tue Oct 25 19:46:59 2011 +0200 @@ -20,7 +20,6 @@ #define HWFORM_H #include -#include #include #include @@ -169,13 +168,12 @@ BGWidget * wBackground; QSignalMapper * pageSwitchMapper; QByteArray m_lastDemo; - QMutex onPageShownMutex; #ifdef __APPLE__ InstallController * panel; #endif - void OnPageShown(quint8 id, quint8 lastid=0); // thread-safe + void OnPageShown(quint8 id, quint8 lastid=0); }; #endif diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/ui/widget/FreqSpinBox.cpp --- a/QTfrontend/ui/widget/FreqSpinBox.cpp Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/ui/widget/FreqSpinBox.cpp Tue Oct 25 19:46:59 2011 +0200 @@ -16,14 +16,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +/** + * @file + * @brief FreqSpinBox class implementation + */ + #include "FreqSpinBox.h" -/** - * Returns it's value as localized frequency. - * 'Never', 'Every Turn', 'Every 2 Turns', etc. - * @param value integer value to be representing as string - * @return the turn frequence-like string representation - */ + +FreqSpinBox::FreqSpinBox(QWidget* parent) : QSpinBox(parent) +{ + // do nothing +}; + + QString FreqSpinBox::textFromValue(int value) const { if (value == 0) diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/ui/widget/FreqSpinBox.h --- a/QTfrontend/ui/widget/FreqSpinBox.h Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/ui/widget/FreqSpinBox.h Tue Oct 25 19:46:59 2011 +0200 @@ -16,15 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef FREQSPINBOX_H -#define FREQSPINBOX_H +/** + * @file + * @brief FreqSpinBox class definition + */ +#ifndef HEDGEWARS_FREQSPINBOX_H +#define HEDGEWARS_FREQSPINBOX_H #include #include /** - * A SpinBox that returns it's value as localized turn frequency. + * SpinBox that returns its value as localized turn frequency. * 'Never', 'Every Turn', 'Every 2 Turns', etc. * @author unc0rr * @since 0.9.12 @@ -34,9 +38,19 @@ Q_OBJECT public: - FreqSpinBox(QWidget* parent) : QSpinBox(parent) {}; + /** + * @brief Class constructor. + * @param parent parent widget. + */ + FreqSpinBox(QWidget * parent); protected: + /** + * Returns it's value as localized frequency. + * 'Never', 'Every Turn', 'Every 2 Turns', etc. + * @param value integer value to be representing as string. + * @return the turn frequence-like string representation. + */ QString textFromValue(int value) const; }; diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/ui/widget/HistoryLineEdit.cpp --- a/QTfrontend/ui/widget/HistoryLineEdit.cpp Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/ui/widget/HistoryLineEdit.cpp Tue Oct 25 19:46:59 2011 +0200 @@ -43,16 +43,6 @@ void HistoryLineEdit::rememberCurrentText() { - m_historyMutex.lock(); - - rememberCurrentTextUnsynced(); - - m_historyMutex.unlock(); -} - - -void HistoryLineEdit::rememberCurrentTextUnsynced() -{ QString newEntry = text(); // don't store whitespace-only/empty text @@ -73,36 +63,26 @@ void HistoryLineEdit::clear() { - m_historyMutex.lock(); - QLineEdit::clear(); m_curHistEntryIdx = m_history->size(); - - m_historyMutex.unlock(); } void HistoryLineEdit::reset() { // forget history - m_historyMutex.lock(); - m_history->clear(); m_curHistEntryIdx = 0; - - m_historyMutex.unlock(); } void HistoryLineEdit::navigateHistory(bool isGoingUp) { - m_historyMutex.lock(); - // save possible changes to new entry if ((m_curHistEntryIdx >= m_history->size() || (text() != m_history->at(m_curHistEntryIdx)))) { - rememberCurrentTextUnsynced(); + rememberCurrentText(); } if (isGoingUp) @@ -125,8 +105,6 @@ else m_curHistEntryIdx = 0; - - m_historyMutex.unlock(); } diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/ui/widget/HistoryLineEdit.h --- a/QTfrontend/ui/widget/HistoryLineEdit.h Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/ui/widget/HistoryLineEdit.h Tue Oct 25 19:46:59 2011 +0200 @@ -32,15 +32,12 @@ #include -#include class QLineEdit; /** * @brief QLineEdit that features a history of previous contents, * re-selectable using the arrow keys. - * - * Note: Public methods for accessing history are thread-safe. * * @author sheepluva * @since 0.9.17 @@ -98,8 +95,6 @@ QStringList * m_history; ///< history of previous inputs - QMutex m_historyMutex; ///< make history QStringList action thread-safe - /** * @brief Navigates content history in the desired direction. * @@ -109,11 +104,6 @@ * @param isGoingUp true: next older entry, false: next more recent entry. */ void navigateHistory(bool isGoingUp); - - /** - * @brief Appends current text to history, without Mutex. - */ - void rememberCurrentTextUnsynced(); }; diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/ui/widget/SmartLineEdit.cpp --- a/QTfrontend/ui/widget/SmartLineEdit.cpp Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/ui/widget/SmartLineEdit.cpp Tue Oct 25 19:46:59 2011 +0200 @@ -53,61 +53,41 @@ void SmartLineEdit::addCommands(const QStringList & commands) { - m_keywordMutex.lock(); - m_cmds->append(commands); - - m_keywordMutex.unlock(); } void SmartLineEdit::removeCommands(const QStringList & commands) { - m_keywordMutex.lock(); - foreach (const QString & cmd, commands) { m_cmds->removeAll(cmd); } - - m_keywordMutex.unlock(); } void SmartLineEdit::addNickname(const QString & name) { - m_keywordMutex.lock(); - m_sorted_nicks->insert(name.toLower(), name); m_nicks->append(name); - - m_keywordMutex.unlock(); } void SmartLineEdit::removeNickname(const QString & name) { - m_keywordMutex.lock(); - m_sorted_nicks->remove(name.toLower()); m_nicks->removeAll(name); - - m_keywordMutex.unlock(); } void SmartLineEdit::reset() { // forget keywords - m_keywordMutex.lock(); - m_cmds->clear(); m_sorted_nicks->clear(); m_nicks->clear(); resetAutoCompletionStatus(); - m_keywordMutex.unlock(); - // forget history HistoryLineEdit::reset(); } @@ -173,10 +153,8 @@ } else { - m_keywordMutex.lock(); m_cmds->sort(); m_nicks = new QStringList(m_sorted_nicks->values()); - m_keywordMutex.unlock(); int cp = cursorPosition(); @@ -211,8 +189,6 @@ } - m_keywordMutex.lock(); - if (isFirstWord) { // find matching commands @@ -250,8 +226,6 @@ } } - m_keywordMutex.unlock(); - // we found a single match? if (!match.isEmpty()) { diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/ui/widget/SmartLineEdit.h --- a/QTfrontend/ui/widget/SmartLineEdit.h Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/ui/widget/SmartLineEdit.h Tue Oct 25 19:46:59 2011 +0200 @@ -44,7 +44,6 @@ *
    *
  • A Keyword can either be a command (if first word) or * a nickname (completed regardless of position in text).
  • - *
  • Public methods for accessing keywords are thread-safe.
  • *
* * @author sheepluva @@ -137,8 +136,6 @@ QString m_prefix; ///< prefix of the text replacement this widget just did QString m_postfix; ///< postfix of the text replacement this widget just did - QMutex m_keywordMutex; ///< make keyword QStringList action thread-safe - /** * @brief Autocompletes the contents based on the known commands and/or names. */ diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/ui/widget/chatwidget.cpp Tue Oct 25 19:46:59 2011 +0200 @@ -102,22 +102,14 @@ QString * HWChatWidget::s_styleSheet = NULL; QStringList * HWChatWidget::s_displayNone = NULL; bool HWChatWidget::s_isTimeStamped = true; -QMutex HWChatWidget::s_styleSheetMutex; const QString & HWChatWidget::styleSheet() { - s_styleSheetMutex.lock(); - if (s_styleSheet != NULL) - { - s_styleSheetMutex.unlock(); return *s_styleSheet; - } setStyleSheet(); - s_styleSheetMutex.unlock(); - return *s_styleSheet; } diff -r 80cd75daf80f -r 7764cbe4ddd7 QTfrontend/ui/widget/chatwidget.h --- a/QTfrontend/ui/widget/chatwidget.h Tue Oct 25 13:30:02 2011 +0400 +++ b/QTfrontend/ui/widget/chatwidget.h Tue Oct 25 19:46:59 2011 +0200 @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "SDLInteraction.h" @@ -87,7 +86,6 @@ static QString * s_styleSheet; static QStringList * s_displayNone; static bool s_isTimeStamped; - static QMutex s_styleSheetMutex; static const QRegExp URLREGEXP; static void setStyleSheet(const QString & styleSheet = "");