Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use static QCoreApplication::processEvents() function without a QApplication instance. #1772

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/rviz/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ int main(int argc, char** argv)
QApplication qapp(argc, argv);

rviz::VisualizerApp vapp;
vapp.setApp(&qapp);
if (vapp.init(argc, argv))
{
return qapp.exec();
Expand Down
36 changes: 13 additions & 23 deletions src/rviz/visualization_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QAction>
#include <QShortcut>
#include <QApplication>
#include <QCoreApplication>
#include <QCloseEvent>
#include <QDesktopServices>
#include <QDockWidget>
Expand Down Expand Up @@ -103,7 +104,6 @@ namespace rviz
{
VisualizationFrame::VisualizationFrame(QWidget* parent)
: QMainWindow(parent)
, app_(nullptr)
, render_panel_(nullptr)
, show_help_action_(nullptr)
, preferences_(new Preferences())
Expand Down Expand Up @@ -166,7 +166,7 @@ VisualizationFrame::~VisualizationFrame()

void VisualizationFrame::setApp(QApplication* app)
{
app_ = app;
Q_UNUSED(app);
}

void VisualizationFrame::setStatus(const QString& message)
Expand Down Expand Up @@ -258,8 +258,7 @@ void VisualizationFrame::initialize(const QString& display_config_file)

// Periodically process events for the splash screen.
// See: http://doc.qt.io/qt-5/qsplashscreen.html#details
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

if (!ros::isInitialized())
{
Expand All @@ -268,8 +267,7 @@ void VisualizationFrame::initialize(const QString& display_config_file)
}

// Periodically process events for the splash screen.
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

QWidget* central_widget = new QWidget(this);
QHBoxLayout* central_layout = new QHBoxLayout;
Expand Down Expand Up @@ -305,40 +303,34 @@ void VisualizationFrame::initialize(const QString& display_config_file)
central_widget->setLayout(central_layout);

// Periodically process events for the splash screen.
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

initMenus();

// Periodically process events for the splash screen.
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

initToolbars();

// Periodically process events for the splash screen.
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

setCentralWidget(central_widget);

// Periodically process events for the splash screen.
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

manager_ = new VisualizationManager(render_panel_, this);
manager_->setHelpPath(help_path_);
connect(manager_, SIGNAL(escapePressed()), this, SLOT(exitFullScreen()));

// Periodically process events for the splash screen.
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

render_panel_->initialize(manager_->getSceneManager(), manager_);

// Periodically process events for the splash screen.
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

ToolManager* tool_man = manager_->getToolManager();

Expand All @@ -351,8 +343,7 @@ void VisualizationFrame::initialize(const QString& display_config_file)
manager_->initialize();

// Periodically process events for the splash screen.
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

if (display_config_file != "")
{
Expand All @@ -364,8 +355,7 @@ void VisualizationFrame::initialize(const QString& display_config_file)
}

// Periodically process events for the splash screen.
if (app_)
app_->processEvents();
QCoreApplication::processEvents();

delete splash_;
splash_ = nullptr;
Expand Down Expand Up @@ -759,7 +749,7 @@ bool VisualizationFrame::loadDisplayConfigHelper(const std::string& full_path, c
dialog.reset(new LoadingDialog(this));
dialog->show();
connect(this, SIGNAL(statusUpdate(const QString&)), dialog.get(), SLOT(showMessage(const QString&)));
app_->processEvents(); // make the window correctly appear although running a long-term function
QCoreApplication::processEvents(); // make the window correctly appear although running a long-term function
}

YamlConfigReader reader;
Expand Down
3 changes: 1 addition & 2 deletions src/rviz/visualization_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class RVIZ_EXPORT VisualizationFrame : public QMainWindow, public WindowManagerI
VisualizationFrame(QWidget* parent = nullptr);
~VisualizationFrame() override;

// now deprecated
ygerlach marked this conversation as resolved.
Show resolved Hide resolved
void setApp(QApplication* app);

/** @brief Call this @e before initialize() to have it take effect. */
Expand Down Expand Up @@ -328,8 +329,6 @@ protected Q_SLOTS:

void hideDockImpl(Qt::DockWidgetArea area, bool hide);

QApplication* app_;

RenderPanel* render_panel_;

QAction* show_help_action_;
Expand Down
5 changes: 2 additions & 3 deletions src/rviz/visualizer_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ bool reloadShaders(std_srvs::Empty::Request& /*unused*/, std_srvs::Empty::Respon
return true;
}

VisualizerApp::VisualizerApp() : app_(nullptr), continue_timer_(nullptr), frame_(nullptr)
VisualizerApp::VisualizerApp() : continue_timer_(nullptr), frame_(nullptr)
{
}

void VisualizerApp::setApp(QApplication* app)
{
app_ = app;
Q_UNUSED(app);
}

bool VisualizerApp::init(int argc, char** argv)
Expand Down Expand Up @@ -202,7 +202,6 @@ bool VisualizerApp::init(int argc, char** argv)
RenderSystem::forceNoStereo();

frame_ = new VisualizationFrame();
frame_->setApp(this->app_);
if (!help_path.empty())
{
frame_->setHelpPath(QString::fromStdString(help_path));
Expand Down
4 changes: 2 additions & 2 deletions src/rviz/visualizer_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#ifndef RVIZ_VISUALIZER_APP_H
#define RVIZ_VISUALIZER_APP_H

#include <QApplication>
#include <QObject>

#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829
Expand All @@ -38,6 +37,7 @@
#include <rviz/SendFilePath.h>
#endif

class QApplication;
class QTimer;

namespace rviz
Expand All @@ -51,6 +51,7 @@ class RVIZ_EXPORT VisualizerApp : public QObject
VisualizerApp();
~VisualizerApp() override;

// now deprecated
ygerlach marked this conversation as resolved.
Show resolved Hide resolved
void setApp(QApplication* app);

/** Start everything. Pass in command line arguments.
Expand All @@ -67,7 +68,6 @@ private Q_SLOTS:
bool loadConfigDiscardingCallback(rviz::SendFilePathRequest& req, rviz::SendFilePathResponse& res);
bool saveConfigCallback(rviz::SendFilePathRequest& req, rviz::SendFilePathResponse& res);

QApplication* app_;
QTimer* continue_timer_;
VisualizationFrame* frame_;
ros::NodeHandlePtr nh_;
Expand Down