From cfa31db743d173189f83c8e589309d852d4a0e80 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Thu, 23 Jan 2003 20:53:40 +0000 Subject: [PATCH] Work around a compiler bug: with (at least) GCC 2.95.3-5 under Cygwin, the destructor for the global s_fileInfo is called twice (!). This does hot happen if a function returning a reference to a static variable is used. (backport) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18892 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/volume.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/msw/volume.cpp b/src/msw/volume.cpp index 6f4ada640d..628dc4e66c 100644 --- a/src/msw/volume.cpp +++ b/src/msw/volume.cpp @@ -102,7 +102,7 @@ static WNetCloseEnumPtr s_pWNetCloseEnum; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ static long s_cancelSearch = FALSE; -struct FileInfo : public wxObject +struct FileInfo { FileInfo(unsigned flag=0, wxFSVolumeKind type=wxFS_VOL_OTHER) : m_flags(flag), m_type(type) {} @@ -119,7 +119,14 @@ struct FileInfo : public wxObject wxFSVolumeKind m_type; }; WX_DECLARE_STRING_HASH_MAP(FileInfo, FileInfoMap); -static FileInfoMap s_fileInfo(25); +// Cygwin bug (?) destructor for global s_fileInfo is called twice... +static FileInfoMap& GetFileInfoMap() +{ + static FileInfoMap s_fileInfo(25); + + return s_fileInfo; +} +#define s_fileInfo (GetFileInfoMap()) //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Other initialization.