Skip to content
Snippets Groups Projects
Commit 16c9928d authored by André Offringa's avatar André Offringa
Browse files

Fix aoqplot -save crash due to uninitialized pango

parent 3010c1e6
Branches
Tags
No related merge requests found
...@@ -71,7 +71,7 @@ ubuntu20-tests: ...@@ -71,7 +71,7 @@ ubuntu20-tests:
- cmake -DENABLE_TESTS=ON -DCMAKE_CXX_FLAGS="-coverage" -DCMAKE_EXE_LINKER_FLAGS="-coverage" ../ - cmake -DENABLE_TESTS=ON -DCMAKE_CXX_FLAGS="-coverage" -DCMAKE_EXE_LINKER_FLAGS="-coverage" ../
# Do not install AOFlagger in this job. The tests should still run. # Do not install AOFlagger in this job. The tests should still run.
- make -j`nproc` all runtests - make -j`nproc` all runtests
- ctest - ctest --output-on-failure
artifacts: artifacts:
paths: paths:
- build/*.xml - build/*.xml
...@@ -94,7 +94,7 @@ ubuntu22-tests: ...@@ -94,7 +94,7 @@ ubuntu22-tests:
- cmake -DENABLE_TESTS=ON -GNinja ../ - cmake -DENABLE_TESTS=ON -GNinja ../
- ninja all runtests install - ninja all runtests install
- ninja check - ninja check
- ctest - ctest --output-on-failure
- cd python - cd python
- echo "import aoflagger"|python3 - echo "import aoflagger"|python3
artifacts: artifacts:
......
...@@ -521,7 +521,7 @@ add_custom_target( ...@@ -521,7 +521,7 @@ add_custom_target(
# TODO(RAP-368) Make a proper integration test target. # TODO(RAP-368) Make a proper integration test target.
option(ENABLE_TESTS option(ENABLE_TESTS
"Enable the integration tests, this requires downloading test data" OFF) "Enable the integration tests. This requires downloading test data." OFF)
if(ENABLE_TESTS) if(ENABLE_TESTS)
find_package(Boost 1.56.0 REQUIRED COMPONENTS unit_test_framework) find_package(Boost 1.56.0 REQUIRED COMPONENTS unit_test_framework)
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include <gtkmm/main.h> #include <gtkmm/main.h>
#include <gtkmm/filechooserdialog.h> #include <gtkmm/filechooserdialog.h>
#include <pangomm/init.h>
#include <version.h> #include <version.h>
#include "../util/logger.h" #include "../util/logger.h"
...@@ -122,6 +124,8 @@ int main(int argc, char* argv[]) { ...@@ -122,6 +124,8 @@ int main(int argc, char* argv[]) {
window->Open(files); window->Open(files);
app->run(*window); app->run(*window);
} else { } else {
Pango::init();
if (files.empty()) { if (files.empty()) {
Logger::Error << "No observation specified.\n"; Logger::Error << "No observation specified.\n";
return 1; return 1;
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include <gtkmm/application.h> #include <gtkmm/application.h>
#include <pangomm/init.h>
#include <glibmm/error.h> #include <glibmm/error.h>
#include <glibmm/wrap.h> #include <glibmm/wrap.h>
...@@ -123,7 +125,7 @@ static void run(int argc, char* argv[]) { ...@@ -123,7 +125,7 @@ static void run(int argc, char* argv[]) {
if (interactive) { if (interactive) {
app = Gtk::Application::create(altArgc, argv, "", app = Gtk::Application::create(altArgc, argv, "",
Gio::APPLICATION_HANDLES_OPEN); Gio::APPLICATION_HANDLES_OPEN);
window.reset(new RFIGuiWindow(&controller, argv[0])); window = std::make_unique<RFIGuiWindow>(&controller, argv[0]);
window->present(); window->present();
} }
...@@ -132,6 +134,7 @@ static void run(int argc, char* argv[]) { ...@@ -132,6 +134,7 @@ static void run(int argc, char* argv[]) {
if (interactive) if (interactive)
window->OpenPaths(filenames); window->OpenPaths(filenames);
else { else {
Pango::init();
MSOptions options; MSOptions options;
options.ioMode = DirectReadMode; options.ioMode = DirectReadMode;
options.dataColumnName = dataColumnName; options.dataColumnName = dataColumnName;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <fstream> #include <fstream>
#include "../lua/default-strategy.h" #include "../lua/default-strategy.h"
#include "../util/logger.h"
Settings::Settings() { Settings::Settings() {
initStrArray("recent-files", std::vector<std::string>(10)); initStrArray("recent-files", std::vector<std::string>(10));
...@@ -25,15 +26,21 @@ std::string Settings::GetStrategyFilename() const { ...@@ -25,15 +26,21 @@ std::string Settings::GetStrategyFilename() const {
std::string Settings::GetConfigDir() { std::string Settings::GetConfigDir() {
std::filesystem::path configPath = std::filesystem::path configPath =
std::filesystem::path(Glib::get_user_config_dir()) / "aoflagger"; std::filesystem::path(Glib::get_user_config_dir()) / "aoflagger";
if (!std::filesystem::is_directory(configPath)) if (!std::filesystem::is_directory(configPath)) {
std::filesystem::create_directory(configPath); // We don't want to crash if the dir can't be created; we will just report
// an error to the cmd line
try {
std::filesystem::create_directories(configPath);
} catch (std::exception& exception) {
Logger::Error << "Failed to create config directory: " << exception.what()
<< '\n';
}
}
return configPath.string(); return configPath.string();
} }
void Settings::InitializeWorkStrategy() { void Settings::InitializeWorkStrategy() {
std::string filename = GetStrategyFilename(); std::string filename = GetStrategyFilename();
// if(!std::filesystem::exists(filename))
//{
std::ofstream str(filename); std::ofstream str(filename);
str.write(reinterpret_cast<const char*>(data_strategies_generic_default_lua), str.write(reinterpret_cast<const char*>(data_strategies_generic_default_lua),
data_strategies_generic_default_lua_len); data_strategies_generic_default_lua_len);
...@@ -41,7 +48,6 @@ void Settings::InitializeWorkStrategy() { ...@@ -41,7 +48,6 @@ void Settings::InitializeWorkStrategy() {
throw std::runtime_error( throw std::runtime_error(
"Failed to write working file for Lua strategy: " + filename + "Failed to write working file for Lua strategy: " + filename +
", size " + std::to_string(data_strategies_generic_default_lua_len)); ", size " + std::to_string(data_strategies_generic_default_lua_len));
//}
} }
void Settings::Load() { void Settings::Load() {
......
...@@ -2,5 +2,7 @@ SRC_DIR = "@CMAKE_SOURCE_DIR@/test/integration" ...@@ -2,5 +2,7 @@ SRC_DIR = "@CMAKE_SOURCE_DIR@/test/integration"
BIN_DIR = "@CMAKE_BINARY_DIR@" BIN_DIR = "@CMAKE_BINARY_DIR@"
RESOURCE_DIR = "@CMAKE_BINARY_DIR@/test_data" RESOURCE_DIR = "@CMAKE_BINARY_DIR@/test_data"
aoflagger = "@CMAKE_BINARY_DIR@/aoflagger" aoflagger = "@CMAKE_BINARY_DIR@/aoflagger"
aoqplot = "@CMAKE_BINARY_DIR@/aoqplot"
aoquality = "@CMAKE_BINARY_DIR@/aoquality" aoquality = "@CMAKE_BINARY_DIR@/aoquality"
rfigui = "@CMAKE_BINARY_DIR@/rfigui"
taql = "@TAQL_EXECUTABLE@" taql = "@TAQL_EXECUTABLE@"
...@@ -44,3 +44,21 @@ def test(): ...@@ -44,3 +44,21 @@ def test():
) )
# Did we write one history record? # Did we write one history record?
assert_taql(f"select from {MS}/HISTORY", 1) assert_taql(f"select from {MS}/HISTORY", 1)
# Test rfigui save baseline functionality (parameters: filename, a1, a2, band, sequence)
# The output isn't checked -- this is just to see if the command succeeds.
check_call(
[
config.rfigui,
MS,
"-save-baseline",
"baseline-test.pdf",
"0",
"1",
"0",
"0",
]
)
# Test if the statistic plots (pdf files) can be saved.
check_call([config.aoqplot, MS, "-save", "test", "StandardDeviation"])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment