Fix tests segfault
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
f60d6e4d48
commit
2030041fcc
@ -99,7 +99,7 @@ if ((CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebI
|
|||||||
message(STATUS "Address Sanitizer enabled for Debug builds, Turn it off with -DDEBUG_ADDRESS_SANITIZER=off")
|
message(STATUS "Address Sanitizer enabled for Debug builds, Turn it off with -DDEBUG_ADDRESS_SANITIZER=off")
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||||
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||||
# using clang with clang-cl front end
|
# using clang with clang-cl front end
|
||||||
message(STATUS "Address Sanitizer available on Clang MSVC frontend")
|
message(STATUS "Address Sanitizer available on Clang MSVC frontend")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /Oy-")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /Oy-")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address /Oy-")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address /Oy-")
|
||||||
@ -225,7 +225,7 @@ set(Launcher_QT_VERSION_MAJOR "6" CACHE STRING "Major Qt version to build agains
|
|||||||
# Java downloader
|
# Java downloader
|
||||||
set(Launcher_ENABLE_JAVA_DOWNLOADER_DEFAULT ON)
|
set(Launcher_ENABLE_JAVA_DOWNLOADER_DEFAULT ON)
|
||||||
|
|
||||||
# Although we recommend enabling this, we cannot guarantee binary compatibility on
|
# Although we recommend enabling this, we cannot guarantee binary compatibility on
|
||||||
# differing Linux/BSD/etc distributions. Downstream packagers should be explicitly opt-ing into this
|
# differing Linux/BSD/etc distributions. Downstream packagers should be explicitly opt-ing into this
|
||||||
# feature if they know it will work with their distribution.
|
# feature if they know it will work with their distribution.
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
@ -438,10 +438,10 @@ elseif(UNIX)
|
|||||||
set(PLUGIN_DEST_DIR "plugins")
|
set(PLUGIN_DEST_DIR "plugins")
|
||||||
set(BUNDLE_DEST_DIR ".")
|
set(BUNDLE_DEST_DIR ".")
|
||||||
set(RESOURCES_DEST_DIR ".")
|
set(RESOURCES_DEST_DIR ".")
|
||||||
|
|
||||||
# Apps to bundle
|
# Apps to bundle
|
||||||
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${Launcher_APP_BINARY_NAME}")
|
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${Launcher_APP_BINARY_NAME}")
|
||||||
|
|
||||||
# directories to look for dependencies
|
# directories to look for dependencies
|
||||||
set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||||
endif()
|
endif()
|
||||||
@ -495,7 +495,7 @@ if(FORCE_BUNDLED_ZLIB)
|
|||||||
set(SKIP_INSTALL_ALL ON)
|
set(SKIP_INSTALL_ALL ON)
|
||||||
add_subdirectory(libraries/zlib EXCLUDE_FROM_ALL)
|
add_subdirectory(libraries/zlib EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
# On OS where unistd.h exists, zlib's generated header defines `Z_HAVE_UNISTD_H`, while the included header does not.
|
# On OS where unistd.h exists, zlib's generated header defines `Z_HAVE_UNISTD_H`, while the included header does not.
|
||||||
# We cannot safely undo the rename on those systems, and they generally have packages for zlib anyway.
|
# We cannot safely undo the rename on those systems, and they generally have packages for zlib anyway.
|
||||||
check_include_file(unistd.h NEED_GENERATED_ZCONF)
|
check_include_file(unistd.h NEED_GENERATED_ZCONF)
|
||||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib/zconf.h.included" AND NOT NEED_GENERATED_ZCONF)
|
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib/zconf.h.included" AND NOT NEED_GENERATED_ZCONF)
|
||||||
@ -533,7 +533,7 @@ endif()
|
|||||||
if(NOT cmark_FOUND)
|
if(NOT cmark_FOUND)
|
||||||
message(STATUS "Using bundled cmark")
|
message(STATUS "Using bundled cmark")
|
||||||
set(BUILD_TESTING 0)
|
set(BUILD_TESTING 0)
|
||||||
set(BUILD_SHARED_LIBS 0)
|
set(BUILD_SHARED_LIBS 0)
|
||||||
add_subdirectory(libraries/cmark EXCLUDE_FROM_ALL) # Markdown parser
|
add_subdirectory(libraries/cmark EXCLUDE_FROM_ALL) # Markdown parser
|
||||||
add_library(cmark::cmark ALIAS cmark)
|
add_library(cmark::cmark ALIAS cmark)
|
||||||
else()
|
else()
|
||||||
|
@ -81,6 +81,12 @@ class Index;
|
|||||||
#endif
|
#endif
|
||||||
#define APPLICATION (static_cast<Application*>(QCoreApplication::instance()))
|
#define APPLICATION (static_cast<Application*>(QCoreApplication::instance()))
|
||||||
|
|
||||||
|
// Used for checking if is a test
|
||||||
|
#if defined(APPLICATION_DYN)
|
||||||
|
#undef APPLICATION_DYN
|
||||||
|
#endif
|
||||||
|
#define APPLICATION_DYN (dynamic_cast<Application*>(QCoreApplication::instance()))
|
||||||
|
|
||||||
class Application : public QApplication {
|
class Application : public QApplication {
|
||||||
// friends for the purpose of limiting access to deprecated stuff
|
// friends for the purpose of limiting access to deprecated stuff
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -608,7 +608,7 @@ set(PRISMUPDATER_SOURCES
|
|||||||
updater/prismupdater/UpdaterDialogs.cpp
|
updater/prismupdater/UpdaterDialogs.cpp
|
||||||
updater/prismupdater/GitHubRelease.h
|
updater/prismupdater/GitHubRelease.h
|
||||||
updater/prismupdater/GitHubRelease.cpp
|
updater/prismupdater/GitHubRelease.cpp
|
||||||
|
|
||||||
Json.h
|
Json.h
|
||||||
Json.cpp
|
Json.cpp
|
||||||
FileSystem.h
|
FileSystem.h
|
||||||
@ -625,7 +625,7 @@ set(PRISMUPDATER_SOURCES
|
|||||||
# Zip
|
# Zip
|
||||||
MMCZip.h
|
MMCZip.h
|
||||||
MMCZip.cpp
|
MMCZip.cpp
|
||||||
|
|
||||||
# Time
|
# Time
|
||||||
MMCTime.h
|
MMCTime.h
|
||||||
MMCTime.cpp
|
MMCTime.cpp
|
||||||
@ -1265,14 +1265,10 @@ include(CompilerWarnings)
|
|||||||
|
|
||||||
# Add executable
|
# Add executable
|
||||||
add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_UI} ${LAUNCHER_RESOURCES})
|
add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_UI} ${LAUNCHER_RESOURCES})
|
||||||
if(BUILD_TESTING)
|
|
||||||
target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_TEST)
|
|
||||||
endif()
|
|
||||||
set_project_warnings(Launcher_logic
|
set_project_warnings(Launcher_logic
|
||||||
"${Launcher_MSVC_WARNINGS}"
|
"${Launcher_MSVC_WARNINGS}"
|
||||||
"${Launcher_CLANG_WARNINGS}"
|
"${Launcher_CLANG_WARNINGS}"
|
||||||
"${Launcher_GCC_WARNINGS}")
|
"${Launcher_GCC_WARNINGS}")
|
||||||
target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION)
|
|
||||||
target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION)
|
target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION)
|
||||||
target_link_libraries(Launcher_logic
|
target_link_libraries(Launcher_logic
|
||||||
@ -1376,7 +1372,7 @@ if(Launcher_BUILD_UPDATER)
|
|||||||
add_executable("${Launcher_Name}_updater" WIN32 updater/prismupdater/updater_main.cpp)
|
add_executable("${Launcher_Name}_updater" WIN32 updater/prismupdater/updater_main.cpp)
|
||||||
target_sources("${Launcher_Name}_updater" PRIVATE updater/prismupdater/updater.exe.manifest)
|
target_sources("${Launcher_Name}_updater" PRIVATE updater/prismupdater/updater.exe.manifest)
|
||||||
target_link_libraries("${Launcher_Name}_updater" prism_updater_logic)
|
target_link_libraries("${Launcher_Name}_updater" prism_updater_logic)
|
||||||
|
|
||||||
if(DEFINED Launcher_APP_BINARY_NAME)
|
if(DEFINED Launcher_APP_BINARY_NAME)
|
||||||
set_target_properties("${Launcher_Name}_updater" PROPERTIES OUTPUT_NAME "${Launcher_APP_BINARY_NAME}_updater")
|
set_target_properties("${Launcher_Name}_updater" PROPERTIES OUTPUT_NAME "${Launcher_APP_BINARY_NAME}_updater")
|
||||||
endif()
|
endif()
|
||||||
|
@ -35,10 +35,9 @@ ResourceFolderModel::ResourceFolderModel(QDir dir, BaseInstance* instance, QObje
|
|||||||
|
|
||||||
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &ResourceFolderModel::directoryChanged);
|
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &ResourceFolderModel::directoryChanged);
|
||||||
connect(&m_helper_thread_task, &ConcurrentTask::finished, this, [this] { m_helper_thread_task.clear(); });
|
connect(&m_helper_thread_task, &ConcurrentTask::finished, this, [this] { m_helper_thread_task.clear(); });
|
||||||
#ifndef LAUNCHER_TEST
|
if (APPLICATION_DYN) { // in tests the application macro doesn't work
|
||||||
// in tests the application macro doesn't work
|
m_helper_thread_task.setMaxConcurrent(APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt());
|
||||||
m_helper_thread_task.setMaxConcurrent(APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt());
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceFolderModel::~ResourceFolderModel()
|
ResourceFolderModel::~ResourceFolderModel()
|
||||||
|
@ -48,7 +48,7 @@ NetJob::NetJob(QString job_name, shared_qobject_ptr<QNetworkAccessManager> netwo
|
|||||||
: ConcurrentTask(nullptr, job_name), m_network(network)
|
: ConcurrentTask(nullptr, job_name), m_network(network)
|
||||||
{
|
{
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#if defined(LAUNCHER_APPLICATION)
|
||||||
if (max_concurrent < 0)
|
if (APPLICATION_DYN && max_concurrent < 0)
|
||||||
max_concurrent = APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt();
|
max_concurrent = APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt();
|
||||||
#endif
|
#endif
|
||||||
if (max_concurrent > 0)
|
if (max_concurrent > 0)
|
||||||
@ -161,7 +161,8 @@ bool NetJob::isOnline()
|
|||||||
void NetJob::emitFailed(QString reason)
|
void NetJob::emitFailed(QString reason)
|
||||||
{
|
{
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#if defined(LAUNCHER_APPLICATION)
|
||||||
if (m_ask_retry && m_manual_try < APPLICATION->settings()->get("NumberOfManualRetries").toInt() && isOnline()) {
|
|
||||||
|
if (APPLICATION_DYN && m_ask_retry && m_manual_try < APPLICATION->settings()->get("NumberOfManualRetries").toInt() && isOnline()) {
|
||||||
m_manual_try++;
|
m_manual_try++;
|
||||||
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
|
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
|
||||||
"The tasks failed.\n"
|
"The tasks failed.\n"
|
||||||
|
@ -31,9 +31,9 @@ QHash<ResourceModel*, bool> ResourceModel::s_running_models;
|
|||||||
ResourceModel::ResourceModel(ResourceAPI* api) : QAbstractListModel(), m_api(api)
|
ResourceModel::ResourceModel(ResourceAPI* api) : QAbstractListModel(), m_api(api)
|
||||||
{
|
{
|
||||||
s_running_models.insert(this, true);
|
s_running_models.insert(this, true);
|
||||||
#ifndef LAUNCHER_TEST
|
if (APPLICATION_DYN) {
|
||||||
m_current_info_job.setMaxConcurrent(APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
m_current_info_job.setMaxConcurrent(APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceModel::~ResourceModel()
|
ResourceModel::~ResourceModel()
|
||||||
@ -60,11 +60,15 @@ auto ResourceModel::data(const QModelIndex& index, int role) const -> QVariant
|
|||||||
return pack->description;
|
return pack->description;
|
||||||
}
|
}
|
||||||
case Qt::DecorationRole: {
|
case Qt::DecorationRole: {
|
||||||
if (auto icon_or_none = const_cast<ResourceModel*>(this)->getIcon(const_cast<QModelIndex&>(index), pack->logoUrl);
|
if (APPLICATION_DYN) {
|
||||||
icon_or_none.has_value())
|
if (auto icon_or_none = const_cast<ResourceModel*>(this)->getIcon(const_cast<QModelIndex&>(index), pack->logoUrl);
|
||||||
return icon_or_none.value();
|
icon_or_none.has_value())
|
||||||
|
return icon_or_none.value();
|
||||||
|
|
||||||
return APPLICATION->getThemedIcon("screenshot-placeholder");
|
return APPLICATION->getThemedIcon("screenshot-placeholder");
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case Qt::SizeHintRole:
|
case Qt::SizeHintRole:
|
||||||
return QSize(0, 58);
|
return QSize(0, 58);
|
||||||
|
Loading…
Reference in New Issue
Block a user