From 12f5e06b92be1b3cbf593e84b76aaefa417ee381 Mon Sep 17 00:00:00 2001 From: cold-brewed <47337035+cold-brewed@users.noreply.github.com> Date: Fri, 14 Apr 2023 13:05:11 -0400 Subject: [PATCH 1/4] viso: Make sure to close file descriptor when a directory is detected (#3251) Co-authored-by: cold-brewed --- src/cdrom/cdrom_image_backend.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cdrom/cdrom_image_backend.c b/src/cdrom/cdrom_image_backend.c index d3f48578d..47dabd37c 100644 --- a/src/cdrom/cdrom_image_backend.c +++ b/src/cdrom/cdrom_image_backend.c @@ -159,7 +159,15 @@ bin_init(const char *filename, int *error) tf->get_length = bin_get_length; tf->close = bin_close; } else { - free(tf); + /* From the check above, error may still be non-zero if opening a directory. + * The error is set for viso to try and open the directory following this function. + * However, we need to make sure the descriptor is closed. */ + if ((tf->file != NULL) && ((stats.st_mode & S_IFMT) == S_IFDIR)) { + /* tf is freed by bin_close */ + bin_close(tf); + } else { + free(tf); + } tf = NULL; } From 7bc213a9544c9d9018fa22e58f81200819d76e3c Mon Sep 17 00:00:00 2001 From: cold-brewed <47337035+cold-brewed@users.noreply.github.com> Date: Fri, 14 Apr 2023 13:48:14 -0400 Subject: [PATCH 2/4] macOS: Bundle fluidsynth and ghostscript (#3250) * macOS: Build fixes for fluidsynth and ghostscript to ensure they get detected and bundled. Add required packages for build. * macOS: Don't link against fluidsynth and only bundle if detected. --------- Co-authored-by: cold-brewed --- .ci/dependencies_macports.txt | 2 ++ src/printer/CMakeLists.txt | 7 +++++++ src/qt/CMakeLists.txt | 29 ++++++++++++++++++++++------- src/sound/CMakeLists.txt | 6 ++++++ 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/.ci/dependencies_macports.txt b/.ci/dependencies_macports.txt index b78331f9e..d73ce7e17 100644 --- a/.ci/dependencies_macports.txt +++ b/.ci/dependencies_macports.txt @@ -11,3 +11,5 @@ vulkan-headers MoltenVK qt5 wget +fluidsynth +ghostscript diff --git a/src/printer/CMakeLists.txt b/src/printer/CMakeLists.txt index ef7b1d5ec..c774258e2 100644 --- a/src/printer/CMakeLists.txt +++ b/src/printer/CMakeLists.txt @@ -14,3 +14,10 @@ # add_library(print OBJECT png.c prt_cpmap.c prt_escp.c prt_text.c prt_ps.c) + +if(APPLE) + find_library(GHOSTSCRIPT_LIB gs) + if (NOT GHOSTSCRIPT_LIB) + message(WARNING "Could not find ghostscript. The library will not be bundled and any related features will not work.") + endif() +endif () \ No newline at end of file diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 944b3359a..d9c729d00 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -299,7 +299,7 @@ endif() # loads a macro to install Qt5 plugins on macOS # based on https://stackoverflow.com/questions/35612687/cmake-macos-x-bundle-with-bundleutiliies-for-qt-application -macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var _prefix) +macro(install_qt5_plugin _qt_plugin_name _runtime_plugins_var _prefix) get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION) if(EXISTS "${_qt_plugin_path}") get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME) @@ -307,7 +307,7 @@ macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var _prefix) get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME) set(_qt_plugin_dest "${_prefix}/PlugIns/${_qt_plugin_type}") install(FILES "${_qt_plugin_path}" DESTINATION "${_qt_plugin_dest}") - list(APPEND ${_qt_plugins_var} "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${_qt_plugin_dest}/${_qt_plugin_file}") + list(APPEND ${_runtime_plugins_var} "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${_qt_plugin_dest}/${_qt_plugin_file}") else() message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found") endif() @@ -320,10 +320,25 @@ if (APPLE AND CMAKE_MACOSX_BUNDLE) set(INSTALL_LIB_DIR "${prefix}/Frameworks") # using the install_qt5_plugin to add Qt plugins into the macOS app bundle - install_qt5_plugin("Qt${QT_MAJOR}::QCocoaIntegrationPlugin" QT_PLUGINS ${prefix}) - install_qt5_plugin("Qt${QT_MAJOR}::QMacStylePlugin" QT_PLUGINS ${prefix}) - install_qt5_plugin("Qt${QT_MAJOR}::QICOPlugin" QT_PLUGINS ${prefix}) - install_qt5_plugin("Qt${QT_MAJOR}::QICNSPlugin" QT_PLUGINS ${prefix}) + install_qt5_plugin("Qt${QT_MAJOR}::QCocoaIntegrationPlugin" RUNTIME_PLUGINS ${prefix}) + install_qt5_plugin("Qt${QT_MAJOR}::QMacStylePlugin" RUNTIME_PLUGINS ${prefix}) + install_qt5_plugin("Qt${QT_MAJOR}::QICOPlugin" RUNTIME_PLUGINS ${prefix}) + install_qt5_plugin("Qt${QT_MAJOR}::QICNSPlugin" RUNTIME_PLUGINS ${prefix}) + + # Install libraries that are loaded at runtime and not linked + if (GHOSTSCRIPT_LIB) + set(GS_LIBRARY_NAME "libgs.dylib") + file(REAL_PATH ${GHOSTSCRIPT_LIB} GS_LIB_RESOLVED) + install(FILES ${GS_LIB_RESOLVED} DESTINATION ${INSTALL_LIB_DIR} RENAME ${GS_LIBRARY_NAME}) + list(APPEND RUNTIME_PLUGINS "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_LIB_DIR}/${GS_LIBRARY_NAME}") + endif () + + if (FLUIDSYNTH_LIB) + set(FLUIDSYNTH_LIBRARY_NAME "libfluidsynth.dylib") + file(REAL_PATH ${FLUIDSYNTH_LIB} FLUIDSYNTH_LIB_RESOLVED) + install(FILES ${FLUIDSYNTH_LIB_RESOLVED} DESTINATION ${INSTALL_LIB_DIR} RENAME ${FLUIDSYNTH_LIBRARY_NAME}) + list(APPEND RUNTIME_PLUGINS "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_LIB_DIR}/${FLUIDSYNTH_LIBRARY_NAME}") + endif () file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "[Paths]\nPlugins = PlugIns\n") @@ -345,7 +360,7 @@ if (APPLE AND CMAKE_MACOSX_BUNDLE) install(CODE " include(BundleUtilities) get_filename_component(CMAKE_INSTALL_PREFIX_ABSOLUTE \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX} ABSOLUTE) - fixup_bundle(\"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/86Box.app\" \"${QT_PLUGINS}\" \"${DIRS}\") + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/86Box.app\" \"${RUNTIME_PLUGINS}\" \"${DIRS}\") execute_process( COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath \"@executable_path/../Frameworks/\" \"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_RUNTIME_DIR}/86Box\") diff --git a/src/sound/CMakeLists.txt b/src/sound/CMakeLists.txt index 10b8903bc..c530d7ac8 100644 --- a/src/sound/CMakeLists.txt +++ b/src/sound/CMakeLists.txt @@ -85,6 +85,12 @@ if(RTMIDI) endif() if(FLUIDSYNTH) + if(APPLE) + find_library(FLUIDSYNTH_LIB fluidsynth) + if (NOT FLUIDSYNTH_LIB) + message(WARNING "Could not find fluid synth. The library will not be bundled and any related features will not work.") + endif() + endif () target_compile_definitions(snd PRIVATE USE_FLUIDSYNTH) target_sources(snd PRIVATE midi_fluidsynth.c) endif() From 0125d144d7fc33814752697b4de269a4f6a89585 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 15 Apr 2023 13:38:38 -0300 Subject: [PATCH 3/4] qt: Use hex debug prints compatible with older Qt versions --- src/qt/evdev_keyboard.cpp | 4 ++-- src/qt/xkbcommon_keyboard.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qt/evdev_keyboard.cpp b/src/qt/evdev_keyboard.cpp index 9dbb4127a..bb932f3b9 100644 --- a/src/qt/evdev_keyboard.cpp +++ b/src/qt/evdev_keyboard.cpp @@ -154,9 +154,9 @@ evdev_translate(uint32_t keycode) if (!ret) qWarning() << "Evdev Keyboard: Unknown key" << keycode; -#if 0 +#if 1 else - qInfo() << "Evdev Keyboard: Key" << keycode << "scancode" << Qt::hex << ret; + qInfo() << "Evdev Keyboard: Key" << keycode << "scancode" << QString::number(ret, 16); #endif return ret; diff --git a/src/qt/xkbcommon_keyboard.cpp b/src/qt/xkbcommon_keyboard.cpp index d370757e2..fc12d0eac 100644 --- a/src/qt/xkbcommon_keyboard.cpp +++ b/src/qt/xkbcommon_keyboard.cpp @@ -224,10 +224,10 @@ xkbcommon_translate(uint32_t keycode) ret = evdev_translate(stoi(key_name_s.substr(1)) - 8); if (!ret) - qWarning() << "XKB Keyboard: Unknown key" << Qt::hex << keycode << QString::fromStdString(key_name_s); -#if 0 + qWarning() << "XKB Keyboard: Unknown key" << QString::number(keycode, 16) << QString::fromStdString(key_name_s); +#if 1 else - qInfo() << "XKB Keyboard: Key" << Qt::hex << keycode << QString::fromStdString(key_name_s) << "scancode" << Qt::hex << ret; + qInfo() << "XKB Keyboard: Key" << QString::number(keycode, 16) << QString::fromStdString(key_name_s) << "scancode" << QString::number(ret, 16); #endif return ret; From 4dbc4a06626bf701cc4b2aab22b92278ba3e3218 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 15 Apr 2023 13:43:23 -0300 Subject: [PATCH 4/4] qt: Disable keyboard debug prints --- src/qt/evdev_keyboard.cpp | 2 +- src/qt/xkbcommon_keyboard.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/evdev_keyboard.cpp b/src/qt/evdev_keyboard.cpp index bb932f3b9..9bc2ebdb2 100644 --- a/src/qt/evdev_keyboard.cpp +++ b/src/qt/evdev_keyboard.cpp @@ -154,7 +154,7 @@ evdev_translate(uint32_t keycode) if (!ret) qWarning() << "Evdev Keyboard: Unknown key" << keycode; -#if 1 +#if 0 else qInfo() << "Evdev Keyboard: Key" << keycode << "scancode" << QString::number(ret, 16); #endif diff --git a/src/qt/xkbcommon_keyboard.cpp b/src/qt/xkbcommon_keyboard.cpp index fc12d0eac..e2e51e7cf 100644 --- a/src/qt/xkbcommon_keyboard.cpp +++ b/src/qt/xkbcommon_keyboard.cpp @@ -225,7 +225,7 @@ xkbcommon_translate(uint32_t keycode) if (!ret) qWarning() << "XKB Keyboard: Unknown key" << QString::number(keycode, 16) << QString::fromStdString(key_name_s); -#if 1 +#if 0 else qInfo() << "XKB Keyboard: Key" << QString::number(keycode, 16) << QString::fromStdString(key_name_s) << "scancode" << QString::number(ret, 16); #endif