| 140 | } |
| 141 | |
| 142 | void |
| 143 | Gui::warningDialog(const std::string & title, |
| 144 | const std::string & text, |
| 145 | bool useHtml) |
| 146 | { |
| 147 | ///don't show dialogs when about to close, otherwise we could enter in a deadlock situation |
| 148 | { |
| 149 | QMutexLocker l(&_imp->aboutToCloseMutex); |
| 150 | if (_imp->_aboutToClose) { |
| 151 | return; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | StandardButtons buttons(eStandardButtonYes | eStandardButtonNo); |
| 156 | |
| 157 | if ( QThread::currentThread() != QCoreApplication::instance()->thread() ) { |
| 158 | QMutexLocker locker(&_imp->_uiUsingMainThreadMutex); |
| 159 | while (_imp->_uiUsingMainThread) { |
| 160 | _imp->_uiUsingMainThreadCond.wait(locker.mutex()); |
| 161 | } |
| 162 | ++_imp->_uiUsingMainThread; |
| 163 | locker.unlock(); |
| 164 | Q_EMIT doDialog(1, QString::fromUtf8( title.c_str() ), QString::fromUtf8( text.c_str() ), useHtml, buttons, (int)eStandardButtonYes); |
| 165 | locker.relock(); |
| 166 | while (_imp->_uiUsingMainThread) { |
| 167 | _imp->_uiUsingMainThreadCond.wait(locker.mutex()); |
| 168 | } |
| 169 | } else { |
| 170 | { |
| 171 | QMutexLocker locker(&_imp->_uiUsingMainThreadMutex); |
| 172 | ++_imp->_uiUsingMainThread; |
| 173 | } |
| 174 | Q_EMIT doDialog(1, QString::fromUtf8( title.c_str() ), QString::fromUtf8( text.c_str() ), useHtml, buttons, (int)eStandardButtonYes); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | void |
| 179 | Gui::warningDialog(const std::string & title, |
no test coverage detected