diff --git a/panda/src/wgldisplay/config_wgldisplay.cxx b/panda/src/wgldisplay/config_wgldisplay.cxx index 1813bdc901..38bbc19fd1 100644 --- a/panda/src/wgldisplay/config_wgldisplay.cxx +++ b/panda/src/wgldisplay/config_wgldisplay.cxx @@ -16,8 +16,6 @@ ConfigureFn(config_wgldisplay) { init_libwgldisplay(); } -string IconFileName = config_wgldisplay.GetString("win32-window-icon",""); - //////////////////////////////////////////////////////////////////// // Function: init_libwgldisplay // Description: Initializes the library. This must be called at @@ -43,3 +41,10 @@ init_libwgldisplay() { wglGraphicsWindow::get_class_type(), wglGraphicsWindow::make_wglGraphicsWindow); } + +// cant use global var cleanly because global var static init executed after init_libwgl(), incorrectly reiniting var +Filename get_icon_filename() { + string iconname = config_wgldisplay.GetString("win32-window-icon",""); + return ExecutionEnvironment::expand_string(iconname); +} + diff --git a/panda/src/wgldisplay/config_wgldisplay.h b/panda/src/wgldisplay/config_wgldisplay.h index a81cb7f070..b31c5aa794 100644 --- a/panda/src/wgldisplay/config_wgldisplay.h +++ b/panda/src/wgldisplay/config_wgldisplay.h @@ -7,11 +7,12 @@ #define __CONFIG_WGLDISPLAY_H__ #include +#include #include NotifyCategoryDecl(wgldisplay, EXPCL_PANDAGL, EXPTP_PANDAGL); -extern string IconFileName; +extern Filename get_icon_filename(); extern EXPCL_PANDAGL void init_libwgldisplay(); diff --git a/panda/src/wgldisplay/wglGraphicsPipe.cxx b/panda/src/wgldisplay/wglGraphicsPipe.cxx index bdd029d1d4..6f96317463 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.cxx +++ b/panda/src/wgldisplay/wglGraphicsPipe.cxx @@ -38,8 +38,12 @@ wglGraphicsPipe::wglGraphicsPipe(const PipeSpecifier& spec) wc.lpszMenuName = NULL; wc.lpszClassName = "wglStandard"; - if(!IconFileName.empty()) { - wc.hIcon = (HICON) LoadImage(NULL, IconFileName.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE); + string windows_icon_filename = get_icon_filename().to_os_specific(); + + if(!windows_icon_filename.empty()) { + // Note: LoadImage seems to cause win2k internal heap corruption (outputdbgstr warnings) + // if icon is more than 8bpp + wc.hIcon = (HICON) LoadImage(NULL, windows_icon_filename.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE); } else { wc.hIcon = NULL; // use default app icon }