5454
5555// Set version number of the library.
5656#ifndef cimg_version
57- #define cimg_version 401
57+ #define cimg_version 402
5858
5959/*-----------------------------------------------------------
6060 #
@@ -8076,6 +8076,7 @@ namespace cimg_library {
80768076
80778077 // Destroy previous display window if existing.
80788078 if (!is_empty()) assign(false);
8079+ if (!dimw || !dimh) return;
80798080
80808081 // Open X11 display and retrieve graphical properties.
80818082 cimg::X11_attr &X11_attr = cimg::X11_attr::ref();
@@ -9440,6 +9441,7 @@ namespace cimg_library {
94409441
94419442 // Destroy previous window if existing.
94429443 if (!is_empty()) assign();
9444+ if (!dimw || !dimh) return;
94439445
94449446 // Set display variables.
94459447 _width = std::min(dimw,(unsigned int)screen_width());
@@ -10138,27 +10140,17 @@ namespace cimg_library {
1013810140 const unsigned int normalization_type=3,
1013910141 const bool is_fullscreen=false, const bool closed_flag=false) {
1014010142
10141- // Destroy previous display window if existing.
10142- if (!is_empty()) assign();
10143- _data = new unsigned int[_width*_height];
10144-
10145- cimg::SDL3_attr &SDL3_attr = cimg::SDL3_attr::ref();
10146- SDL3_attr.lock();
10147-
10148- if (SDL3_attr.nb_cimg_displays>=512) {
10149- SDL3_attr.unlock();
10150- throw CImgDisplayException("CImgDisplay::assign(): Max number of displays (512) already opened.");
10151- }
10152-
1015310143 // Allocate space for window title.
1015410144 const char *const np_title = p_title?p_title:"";
1015510145 const unsigned int s = (unsigned int)std::strlen(np_title) + 1;
1015610146 char *const tmp_title = s?new char[s]:0;
1015710147 if (s) std::memcpy(tmp_title,np_title,s*sizeof(char));
1015810148
10149+ // Destroy previous display window if existing.
10150+ if (!is_empty()) assign();
10151+ if (!dimw || !dimh) return;
10152+
1015910153 // Set display variables.
10160- _width = std::min(dimw,(unsigned int)screen_width());
10161- _height = std::min(dimh,(unsigned int)screen_height());
1016210154 _normalization = normalization_type<4?normalization_type:3;
1016310155 _is_fullscreen = is_fullscreen;
1016410156 _window_x = _window_y = cimg::type<int>::min();
@@ -10167,6 +10159,16 @@ namespace cimg_library {
1016710159 _paint_request = false;
1016810160 _title = tmp_title;
1016910161 _thread_id = SDL_GetCurrentThreadID();
10162+ _width = std::min(dimw,(unsigned int)screen_width());
10163+ _height = std::min(dimh,(unsigned int)screen_height());
10164+ _data = new unsigned int[_width*_height];
10165+
10166+ cimg::SDL3_attr &SDL3_attr = cimg::SDL3_attr::ref();
10167+ SDL3_attr.lock();
10168+ if (SDL3_attr.nb_cimg_displays>=512) {
10169+ SDL3_attr.unlock();
10170+ throw CImgDisplayException("CImgDisplay::assign(): Max number of displays (512) already opened.");
10171+ }
1017010172 flush();
1017110173
1017210174 // Create window and renderer.
0 commit comments