Fixing error to create the window in a safely way

This commit is contained in:
Pcornat 2025-05-30 22:43:24 +02:00
parent ac620fb3b7
commit aea1ee6822
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD
2 changed files with 12 additions and 3 deletions

View file

@ -12,9 +12,18 @@ namespace data {
} }
namespace gui { namespace gui {
using modulesType = std::unordered_map<std::string, data::BasicData *>;
class Window;
[[nodiscard]] static std::optional<Window> create_window(
const GLFWerrorfun errorCallback,
GLFWframebuffersizefun framebufferCallback,
const bool debugOpengl,
GLFWwindow *shared,
std::initializer_list<modulesType::value_type> initializer) noexcept;
class Window final { class Window final {
public: public:
using modulesType = std::unordered_map<std::string, data::BasicData *>;
using windowPtr = GLFWwindow *; using windowPtr = GLFWwindow *;
private: private:
@ -56,7 +65,7 @@ namespace gui {
GLFWframebuffersizefun framebufferCallback, GLFWframebuffersizefun framebufferCallback,
const bool debugOpengl, const bool debugOpengl,
GLFWwindow *shared, GLFWwindow *shared,
std::initializer_list<Window::modulesType::value_type> initializer) noexcept; std::initializer_list<modulesType::value_type> initializer) noexcept;
~Window() noexcept; ~Window() noexcept;

View file

@ -116,7 +116,7 @@ namespace gui {
const GLFWframebuffersizefun framebufferCallback, const GLFWframebuffersizefun framebufferCallback,
const bool debugOpengl, const bool debugOpengl,
GLFWwindow *shared, GLFWwindow *shared,
const std::initializer_list<Window::modulesType::value_type> initializer const std::initializer_list<modulesType::value_type> initializer
) noexcept { ) noexcept {
if (!init) { if (!init) {
glfwSetErrorCallback(errorCallback); glfwSetErrorCallback(errorCallback);