From dabd57847edf142f145491175fb203455023d9d7 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Wed, 20 Apr 2016 13:50:41 +0600 Subject: [PATCH] MSVC: work around binary size explosion. --- src/solvespace.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/solvespace.h b/src/solvespace.h index 910cdfc..989476b 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -681,7 +681,8 @@ public: class SolveSpaceUI { public: - TextWindow TW; + TextWindow *pTW; + TextWindow &TW; GraphicsWindow GW; // The state for undo/redo @@ -923,7 +924,8 @@ public: bool ActiveGroupsOkay(void); // The system to be solved. - System sys; + System *pSys; + System &sys; // All the TrueType fonts in memory TtfFontList fonts; @@ -945,6 +947,18 @@ public: static void MenuHelp(int id); void Clear(void); + + // We allocate TW and sys on the heap to work around an MSVC problem + // where it puts zero-initialized global data in the binary (~30M of zeroes) + // in release builds. + SolveSpaceUI() + : pTW(new TextWindow({})), TW(*pTW), + pSys(new System({})), sys(*pSys) {} + + ~SolveSpaceUI() { + delete pTW; + delete pSys; + } }; extern SolveSpaceUI SS;