Skip to content

Commit

Permalink
Suppress new Jammy warnings (#404)
Browse files Browse the repository at this point in the history
* Use explicit functions for Connections

Cleans up corresponding deprecation warnings

Signed-off-by: Michael Carroll <[email protected]>

* Clean up log spew related to "Cannot read property"

Signed-off-by: Michael Carroll <[email protected]>

* More log spew cleanup

This narrows the warnings to LoadBadInheritancePlugin.

Signed-off-by: Michael Carroll <[email protected]>

* Lint

Signed-off-by: Michael Carroll <[email protected]>

* Add backward to debug

Signed-off-by: Michael Carroll <[email protected]>

* Fix race in camera_tracking

Signed-off-by: Michael Carroll <[email protected]>

* Remove unloadEngine call

Signed-off-by: Michael Carroll <[email protected]>

* Examples quality of life improvements

Signed-off-by: Michael Carroll <[email protected]>

* Lint

Signed-off-by: Michael Carroll <[email protected]>

* Iteration

Signed-off-by: Michael Carroll <[email protected]>

* Don't unload anywhere

Signed-off-by: Michael Carroll <[email protected]>

* Add a sleep for testing

Signed-off-by: Michael Carroll <[email protected]>

* Force processing events

Signed-off-by: Michael Carroll <[email protected]>

* Remove backward

Signed-off-by: Michael Carroll <[email protected]>

* Undo examples changes

Signed-off-by: Michael Carroll <[email protected]>

* Change inheritance in test

Signed-off-by: Michael Carroll <[email protected]>

* Fix Windows warning

Signed-off-by: Michael Carroll <[email protected]>

---------

Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll authored Aug 28, 2023
1 parent 7c4c683 commit 181a0d5
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 97 deletions.
4 changes: 2 additions & 2 deletions include/gz/gui/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ ApplicationWindow
// C++ signals to QML slots
Connections {
target: MainWindow
onNotify: {
function onNotify(_message) {
notificationDialog.setTextDuration(_message, 0)
}
onNotifyWithDuration: {
function onNotifyWithDuration(_message, _duration) {
notificationDialog.setTextDuration(_message, _duration)
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/gz/gui/qml/PluginMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Popup {

Connections {
target: MainWindow
onConfigChanged: {
function onConfigChanged() {
filteredModel.model = MainWindow.PluginListModel()
}
}
Expand Down
6 changes: 3 additions & 3 deletions include/gz/gui/qml/StyleDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ Dialog {
// Connections (C++ signal to QML slot)
Connections {
target: MainWindow
onMaterialThemeChanged: {
function onMaterialThemeChanged() {
updateTheme(MainWindow.materialTheme);
}
}

Connections {
target: MainWindow
onMaterialPrimaryChanged: {
function onMaterialPrimaryChanged() {
updatePrimary(MainWindow.materialPrimary);
}
}

Connections {
target: MainWindow
onMaterialAccentChanged: {
function onMaterialAccentChanged() {
updateAccent(MainWindow.materialAccent);
}
}
Expand Down
19 changes: 12 additions & 7 deletions src/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ Application::~Application()
}
if (this->dataPtr->mainWin->QuickWindow()->isVisible())
this->dataPtr->mainWin->QuickWindow()->close();
delete this->dataPtr->mainWin;
this->dataPtr->mainWin = nullptr;
this->dataPtr->mainWin->deleteLater();
}

for (auto dialog : this->dataPtr->dialogs)
Expand All @@ -264,10 +263,7 @@ Application::~Application()
}
this->dataPtr->dialogs.clear();

if (this->dataPtr->engine)
{
this->dataPtr->engine->deleteLater();
}
delete this->dataPtr->engine;

std::queue<std::shared_ptr<Plugin>> empty;
std::swap(this->dataPtr->pluginsToAdd, empty);
Expand Down Expand Up @@ -385,11 +381,20 @@ bool Application::LoadConfig(const std::string &_config)
this->dataPtr->pluginsAdded.clear();

// Process each plugin
bool successful = true;
for (auto pluginElem = doc.FirstChildElement("plugin"); pluginElem != nullptr;
pluginElem = pluginElem->NextSiblingElement("plugin"))
{
auto filename = pluginElem->Attribute("filename");
this->LoadPlugin(filename, pluginElem);
if (!this->LoadPlugin(filename, pluginElem))
{
successful = false;
}
}

if (!successful)
{
return false;
}

// Process window properties
Expand Down
155 changes: 89 additions & 66 deletions src/Application_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor))
common::Console::SetVerbosity(4);

// No Qt app
EXPECT_EQ(nullptr, qGuiApp);
EXPECT_EQ(nullptr, App());
ASSERT_EQ(nullptr, qGuiApp);
ASSERT_EQ(nullptr, App());

// One app construct - destruct
{
Expand All @@ -65,93 +65,116 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor))
//////////////////////////////////////////////////
TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadPlugin))
{
common::Console::SetVerbosity(4);
gz::common::Console::SetVerbosity(4);

// No Qt app
EXPECT_EQ(nullptr, qGuiApp);

// Official plugin
{
Application app(g_argc, g_argv);
ASSERT_EQ(nullptr, qGuiApp);
Application app(g_argc, g_argv);

EXPECT_TRUE(app.LoadPlugin("Publisher"));
}
EXPECT_TRUE(app.LoadPlugin("Publisher"));
}
//////////////////////////////////////////////////
TEST(ApplicationTest,
GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadNonexistantPlugin))
{
gz::common::Console::SetVerbosity(4);
// No Qt app
ASSERT_EQ(nullptr, qGuiApp);
Application app(g_argc, g_argv);

// Inexistent plugin
{
Application app(g_argc, g_argv);
EXPECT_FALSE(app.LoadPlugin("_doesnt_exist"));
EXPECT_FALSE(app.RemovePlugin("_doesnt_exist"));
}

EXPECT_FALSE(app.LoadPlugin("_doesnt_exist"));
EXPECT_FALSE(app.RemovePlugin("_doesnt_exist"));
}
//////////////////////////////////////////////////
TEST(ApplicationTest,
GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadProgrammaticPlugin))
{
gz::common::Console::SetVerbosity(4);
// No Qt app
ASSERT_EQ(nullptr, qGuiApp);
Application app(g_argc, g_argv);

// Plugin path added programmatically
std::string pluginName;
app.connect(&app, &Application::PluginAdded, [&pluginName](
const QString &_pluginName)
{
Application app(g_argc, g_argv);

std::string pluginName;
app.connect(&app, &Application::PluginAdded, [&pluginName](
const QString &_pluginName)
{
pluginName = _pluginName.toStdString();
});
pluginName = _pluginName.toStdString();
});

app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");
app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");

EXPECT_TRUE(app.LoadPlugin("TestPlugin"));
EXPECT_EQ(0u, pluginName.find("plugin"));
EXPECT_TRUE(app.LoadPlugin("TestPlugin"));
EXPECT_EQ(0u, pluginName.find("plugin"));

auto plugin = app.PluginByName(pluginName);
ASSERT_NE(nullptr, plugin);
ASSERT_NE(nullptr, plugin->CardItem());
auto plugin = app.PluginByName(pluginName);
ASSERT_NE(nullptr, plugin);
ASSERT_NE(nullptr, plugin->CardItem());

EXPECT_EQ(pluginName, plugin->CardItem()->objectName().toStdString());
EXPECT_EQ(pluginName, plugin->CardItem()->objectName().toStdString());

EXPECT_TRUE(app.RemovePlugin(pluginName));
}

// Plugin path added by env var
{
setenv("TEST_ENV_VAR",
(std::string(PROJECT_BINARY_PATH) + "/lib").c_str(), 1);
EXPECT_TRUE(app.RemovePlugin(pluginName));
}

Application app(g_argc, g_argv);
app.SetPluginPathEnv("TEST_ENV_VAR");
//////////////////////////////////////////////////
TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadEnvPlugin))
{
gz::common::Console::SetVerbosity(4);
// No Qt app
ASSERT_EQ(nullptr, qGuiApp);
Application app(g_argc, g_argv);

EXPECT_TRUE(app.LoadPlugin("TestPlugin"));
}
setenv("TEST_ENV_VAR",
(std::string(PROJECT_BINARY_PATH) + "/lib").c_str(), 1);
app.SetPluginPathEnv("TEST_ENV_VAR");
EXPECT_TRUE(app.LoadPlugin("TestPlugin"));
}

// Plugin which doesn't inherit from gui::Plugin
{
Application app(g_argc, g_argv);
app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");
//////////////////////////////////////////////////
TEST(ApplicationTest,
GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadBadInheritancePlugin))
{
gz::common::Console::SetVerbosity(4);
// No Qt app
ASSERT_EQ(nullptr, qGuiApp);
Application app(g_argc, g_argv);

EXPECT_FALSE(app.LoadPlugin("TestBadInheritancePlugin"));
}
app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");
EXPECT_FALSE(app.LoadPlugin("TestBadInheritancePlugin"));
}

// Plugin which is not registered
{
Application app(g_argc, g_argv);
app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");
//////////////////////////////////////////////////
TEST(ApplicationTest,
GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadNotRegisteredPlugin))
{
gz::common::Console::SetVerbosity(4);
// No Qt app
ASSERT_EQ(nullptr, qGuiApp);
Application app(g_argc, g_argv);

EXPECT_FALSE(app.LoadPlugin("TestNotRegisteredPlugin"));
}
app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");
EXPECT_FALSE(app.LoadPlugin("TestNotRegisteredPlugin"));
}

// Plugin with invalid QML
{
Application app(g_argc, g_argv);
app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");
//////////////////////////////////////////////////
TEST(ApplicationTest,
GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadInvalidQmlPlugin))
{
gz::common::Console::SetVerbosity(4);
// No Qt app
ASSERT_EQ(nullptr, qGuiApp);
Application app(g_argc, g_argv);

EXPECT_FALSE(app.LoadPlugin("TestInvalidQmlPlugin"));
}
app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");
EXPECT_FALSE(app.LoadPlugin("TestInvalidQmlPlugin"));
}

//////////////////////////////////////////////////
TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadConfig))
{
common::Console::SetVerbosity(4);

EXPECT_EQ(nullptr, qGuiApp);
ASSERT_EQ(nullptr, qGuiApp);

// Empty string
{
Expand Down Expand Up @@ -201,7 +224,7 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadDefaultConfig))
{
common::Console::SetVerbosity(4);

EXPECT_EQ(nullptr, qGuiApp);
ASSERT_EQ(nullptr, qGuiApp);

// Test config file
{
Expand All @@ -227,7 +250,7 @@ TEST(ApplicationTest,
{
common::Console::SetVerbosity(4);

EXPECT_EQ(nullptr, qGuiApp);
ASSERT_EQ(nullptr, qGuiApp);

// No plugins
{
Expand Down Expand Up @@ -297,7 +320,7 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog))
{
common::Console::SetVerbosity(4);

EXPECT_EQ(nullptr, qGuiApp);
ASSERT_EQ(nullptr, qGuiApp);

// Single dialog
{
Expand Down Expand Up @@ -372,7 +395,7 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(messageHandler))
{
common::Console::SetVerbosity(4);

EXPECT_EQ(nullptr, qGuiApp);
ASSERT_EQ(nullptr, qGuiApp);

Application app(g_argc, g_argv);

Expand Down
15 changes: 10 additions & 5 deletions src/MainWindow_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor))
auto mainWindow = new MainWindow;
ASSERT_NE(nullptr, mainWindow);

delete mainWindow;
mainWindow->deleteLater();
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -91,7 +91,7 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(OnSaveConfig))
std::remove(kTestConfigFile.c_str());
}

delete mainWindow;
mainWindow->deleteLater();
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -127,7 +127,7 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(SaveConfigAs))
std::remove(kTestConfigFile.c_str());
}

delete mainWindow;
mainWindow->deleteLater();
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -720,6 +720,8 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ApplyConfig))
auto mainWindow = new MainWindow;
ASSERT_NE(nullptr, mainWindow);

app.processEvents(QEventLoop::ExcludeUserInputEvents);

// Default config
{
auto c = mainWindow->CurrentWindowConfig();
Expand All @@ -729,6 +731,7 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ApplyConfig))
EXPECT_TRUE(c.pluginsFromPaths);
EXPECT_TRUE(c.showPlugins.empty());
EXPECT_TRUE(c.ignoredProps.empty());

}

// Apply a config
Expand All @@ -746,9 +749,11 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ApplyConfig))
// c.showPlugins.push_back("watermelon");
// c.ignoredProps.insert("position");

mainWindow->ApplyConfig(c);
EXPECT_TRUE(mainWindow->ApplyConfig(c));
}

app.processEvents(QEventLoop::ExcludeUserInputEvents);

// Check applied config
{
auto c = mainWindow->CurrentWindowConfig();
Expand All @@ -769,5 +774,5 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ApplyConfig))
// EXPECT_EQ(c.ignoredProps.size(), 1u);
}

delete mainWindow;
mainWindow->deleteLater();
}
2 changes: 1 addition & 1 deletion src/plugins/grid_config/GridConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ GridLayout {

Connections {
target: GridConfig
onNewParams: {
function onNewParams(_hCellCount, _vCellCount, _cellLength, _pos, _rot, _color) {
horizontalCellCount.value = _hCellCount;
verticalCellCount.value = _vCellCount;
cellLength.value = _cellLength;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/image_display/ImageDisplay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Rectangle {

Connections {
target: ImageDisplay
onNewImage: image.reload();
function onNewImage(){ image.reload(); }
}

ColumnLayout {
Expand Down
Loading

0 comments on commit 181a0d5

Please sign in to comment.