Closed zenakuten closed 6 years ago
What SFML version are you using?
It's 0.3.2. I'm building from source from this tankOs/SFGU git repo. I'm using Windows 10 + Visual Studio 2017 (15.5) with Intel 520HD graphics.
I meant the SFML version not the SFGUI one. 😉
Oh :) It's the latest SFML version also (2.4.2 from CMakeLists.txt). In my project I'm pulling it directly from https://github.com/SFML/SFML and building from source. I'm linking SFGUI against this source build.
While I haven't experienced any crashes, but haven't tried sf::Style::None, there seems to be some issues with the latest version of SFML and SFGUI. Maybe there need to be some fixes with context management, @binary1248?
I was testing out trying to create a minimal project that demonstrates this. I tried running the app various ways, and I only see the crash inside the debugger.
Exception thrown at 0x774213C5 (ntdll.dll) in HelloWorld.exe: 0xC0000005: Access violation reading location 0x00000008.
This is in SFML WglContext at line 287: bool isValid = wglChoosePixelFormatARB(deviceContext, intAttributes, NULL, 512, formats, &nbFormats) != FALSE;
Walking up the stack this is happening because SFGUI is creating the context I originally mentioned. Everything is getting deleted at this point (application exit) so this code blows up. deviceContext is invalid memory.
Here is the basis of my project. If you create a folder with this CMakeLists.txt, copy HelloWorld.cpp to the root, then make the sf::Style::None change, and then run through the debugger in Visual Studio, it crashes on exit.
---CMakeLists.txt ---- cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
project( test )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF)
include_directories( ${PROJECT_SOURCE_DIR}/src/include ) include_directories( ${CMAKE_CURRENT_BINARY_DIR}/include ) link_directories(${PROJECT_SOURCE_DIR}/lib)
include(ExternalProject) include(FindPackageHandleStandardArgs) ExternalProject_Add( SFML PREFIX ${PROJECT_SOURCE_DIR}/external/SFML BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/SFML STAMP_DIR ${PROJECT_SOURCE_DIR}/stamp/SFML GIT_REPOSITORY https://github.com/SFML/SFML.git INSTALL_DIR ${PROJECT_SOURCE_DIR}/external/SFML CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/external/SFML -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${PROJECT_SOURCE_DIR}/bin -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${PROJECT_SOURCE_DIR}/bin -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${PROJECT_SOURCE_DIR}/lib UPDATE_COMMAND "" ) include_directories(${PROJECT_SOURCE_DIR}/external/SFML/include)
set(SFML_ROOT ${PROJECT_SOURCE_DIR}/external/SFML) ExternalProject_Add( sfgui BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/sfgui PREFIX ${PROJECT_SOURCE_DIR}/external/sfgui CMAKE_ARGS -DSFGUI_BUILD_EXAMPLES=true -DSFML_ROOT=${SFML_ROOT} -DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/external/sfgui -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${PROJECT_SOURCE_DIR}/bin -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${PROJECT_SOURCE_DIR}/bin -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${PROJECT_SOURCE_DIR}/lib STAMP_DIR ${PROJECT_SOURCE_DIR}/stamp/sfgui GIT_REPOSITORY https://github.com/TankOs/SFGUI INSTALL_DIR ${PROJECT_SOURCE_DIR}/external/sfgui UPDATE_COMMAND "" DEPENDS SFML ) include_directories(${PROJECT_SOURCE_DIR}/external/sfgui/include)
add_executable(testapp HelloWorld.cpp) if(${CMAKE_CONFIGURATION_TYPES} STREQUAL "Debug") target_link_libraries(testapp opengl32 sfgui-d.lib sfml-audio-d.lib sfml-graphics-d.lib sfml-main-d.lib sfml-network-d.lib sfml-system-d.lib sfml-window-d.lib ) else() target_link_libraries(testapp opengl32 sfgui.lib sfml-audio.lib sfml-graphics.lib sfml-main.lib sfml-network.lib sfml-system.lib sfml-window.lib ) endif() ----- CMakeLists.txt ----
Just tested with current master and SFML 2.5, cannot reproduce.
When I run the example hello world app, and change the style to sf::Style::None, the app crashes on exit inside SFML. I traced it down to the destructor for NonLegacyRenderer. In NonLegacyRenderer.cpp at line 308 a context is created with sf::Context context. If I comment that out it no longer crashes.
Should the destructor be creating a context at application exit? I don't believe any of the gl delete calls need it.