Browse Source

Fixed multi-thread message window bug, mainwindow should not hang any more on message windows from comm threads

QGC4.4
pixhawk 14 years ago
parent
commit
835279e9a6
  1. 10
      src/comm/MAVLinkProtocol.cc
  2. 30
      src/ui/MainWindow.cc
  3. 21
      src/ui/MainWindow.h

10
src/comm/MAVLinkProtocol.cc

@ -164,13 +164,9 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) @@ -164,13 +164,9 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
if (heartbeat.mavlink_version != MAVLINK_VERSION)
{
// Bring up dialog to inform user
QMessageBox msgBox(MainWindow::instance());
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(tr("The MAVLink protocol version on the MAV and QGroundControl mismatch!"));
msgBox.setInformativeText(tr("It is unsafe to use different MAVLink versions. QGroundControl therefore refuses to connect to system %1, which sends MAVLink version %2 (QGroundControl uses version %3).").arg(message.sysid).arg(heartbeat.mavlink_version).arg(MAVLINK_VERSION));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
MainWindow::instance()->showCriticalMessage(tr("The MAVLink protocol version on the MAV and QGroundControl mismatch!"),
tr("It is unsafe to use different MAVLink versions. QGroundControl therefore refuses to connect to system %1, which sends MAVLink version %2 (QGroundControl uses version %3).").arg(message.sysid).arg(heartbeat.mavlink_version).arg(MAVLINK_VERSION));
// Ignore this message and continue gracefully
continue;

30
src/ui/MainWindow.cc

@ -882,17 +882,37 @@ void MainWindow::reloadStylesheet() @@ -882,17 +882,37 @@ void MainWindow::reloadStylesheet()
delete styleSheet;
}
/**
* The status message will be overwritten if a new message is posted to this function
*
* @param status message text
* @param timeout how long the status should be displayed
*/
void MainWindow::showStatusMessage(const QString& status, int timeout)
{
Q_UNUSED(status);
Q_UNUSED(timeout);
//statusBar->showMessage(status, timeout);
statusBar->showMessage(status, timeout);
}
/**
* The status message will be overwritten if a new message is posted to this function.
* it will be automatically hidden after 5 seconds.
*
* @param status message text
*/
void MainWindow::showStatusMessage(const QString& status)
{
Q_UNUSED(status);
//statusBar->showMessage(status, 5);
statusBar->showMessage(status, 5);
}
void MainWindow::showCriticalMessage(const QString& title, const QString& message)
{
QMessageBox msgBox(MainWindow::instance());
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(title);
msgBox.setInformativeText(message);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
/**

21
src/ui/MainWindow.h

@ -92,24 +92,13 @@ public slots: @@ -92,24 +92,13 @@ public slots:
// /** @brief Store the mainwindow settings */
// void storeSettings();
/**
* @brief Shows a status message on the bottom status bar
*
* The status message will be overwritten if a new message is posted to this function
*
* @param status message text
* @param timeout how long the status should be displayed
*/
/** @brief Shows a status message on the bottom status bar */
void showStatusMessage(const QString& status, int timeout);
/**
* @brief Shows a status message on the bottom status bar
*
* The status message will be overwritten if a new message is posted to this function.
* it will be automatically hidden after 5 seconds.
*
* @param status message text
*/
/** @brief Shows a status message on the bottom status bar */
void showStatusMessage(const QString& status);
/** @brief Shows a critical message as popup or as widget */
void showCriticalMessage(const QString& title, const QString& message);
void addLink();
void addLink(LinkInterface* link);
void configure();

Loading…
Cancel
Save