Skip to content

Commit

Permalink
use static QCoreApplication::processEvents() function without a QAppl…
Browse files Browse the repository at this point in the history
…ication instance (#924)

* fix posible segfault, use static processEvents()

* do not process app_ if it is not set

* Fix uncrustify warning.

Co-authored-by: Chris Lalancette <[email protected]>
  • Loading branch information
ygerlach and clalancette authored Jul 6, 2023
1 parent 733350f commit 439c683
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions rviz_common/src/rviz_common/visualization_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ void VisualizationFrame::initialize(

loadPersistentSettings();

QDir app_icon_path(QString::fromStdString(package_path_) + "/icons/package.png");
QIcon app_icon(app_icon_path.absolutePath());
app_->setWindowIcon(app_icon);
if (app_) {
QDir app_icon_path(QString::fromStdString(package_path_) + "/icons/package.png");
QIcon app_icon(app_icon_path.absolutePath());
app_->setWindowIcon(app_icon);
}

if (splash_path_ != "") {
QPixmap splash_image(splash_path_);
Expand All @@ -265,10 +267,10 @@ void VisualizationFrame::initialize(

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

// 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,22 +307,22 @@ void VisualizationFrame::initialize(
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();

// TODO(wjwwood): sort out the issue with initialization order between
// render_panel and VisualizationManager
Expand All @@ -332,12 +334,12 @@ void VisualizationFrame::initialize(
panel_factory_ = new PanelFactory(rviz_ros_node_, manager_);

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

render_panel_->initialize(manager_);

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

ToolManager * tool_man = manager_->getToolManager();

Expand All @@ -350,7 +352,7 @@ void VisualizationFrame::initialize(
manager_->initialize();

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

if (display_config_file != "") {
loadDisplayConfig(display_config_file);
Expand All @@ -359,7 +361,7 @@ void VisualizationFrame::initialize(
}

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

delete splash_;
splash_ = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion rviz_common/src/rviz_common/visualizer_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ bool VisualizerApp::init(int argc, char ** argv)
// bool disable_anti_aliasing = false;
// bool disable_stereo = false;

parser.process(*app_);
if (app_) {parser.process(*app_);}

enable_ogre_log = parser.isSet(ogre_log_option);
// disable_stereo = parser.isSet(no_stereo_option);
Expand Down

0 comments on commit 439c683

Please sign in to comment.