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

Suppress new Jammy warnings #404

Merged
merged 20 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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 @@
}
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 @@
}
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 @@
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;

Check warning on line 391 in src/Application.cc

View check run for this annotation

Codecov / codecov/patch

src/Application.cc#L391

Added line #L391 was not covered by tests
}
}

if (!successful)
{
return false;

Check warning on line 397 in src/Application.cc

View check run for this annotation

Codecov / codecov/patch

src/Application.cc#L397

Added line #L397 was not covered by tests
}

// 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