-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PixelCounting exception thrown by OpenGL destruction in Windows. #9257
Changes from 2 commits
401a9ad
36b9d15
6a873b9
7627a7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,21 +50,24 @@ | |
#include <EnergyPlus/Data/EnergyPlusData.hh> | ||
#include <EnergyPlus/DataStringGlobals.hh> | ||
#include <EnergyPlus/api/EnergyPlusPgm.hh> | ||
#include <EnergyPlus/api/state.h> | ||
|
||
int main(int argc, const char *argv[]) | ||
{ | ||
EnergyPlus::EnergyPlusData state; | ||
EnergyPlus::EnergyPlusData *state = reinterpret_cast<EnergyPlus::EnergyPlusData*>(stateNew()); | ||
// these need to be set early to be used in help and version output messaging | ||
// this was pulled from EnergyPlusPgm.cc and needs to be removed once the release is done | ||
Array1D_int value(8); | ||
std::string datestring; // supposedly returns blank when no date available. | ||
date_and_time(datestring, _, _, value); | ||
if (!datestring.empty()) { | ||
state.dataStrGlobals->CurrentDateTime = fmt::format(" YMD={:4}.{:02}.{:02} {:02}:{:02}", value(1), value(2), value(3), value(5), value(6)); | ||
state->dataStrGlobals->CurrentDateTime = fmt::format(" YMD={:4}.{:02}.{:02} {:02}:{:02}", value(1), value(2), value(3), value(5), value(6)); | ||
} else { | ||
state.dataStrGlobals->CurrentDateTime = " unknown date/time"; | ||
state->dataStrGlobals->CurrentDateTime = " unknown date/time"; | ||
} | ||
state.dataStrGlobals->VerStringVar = EnergyPlus::DataStringGlobals::VerString + "," + state.dataStrGlobals->CurrentDateTime; | ||
EnergyPlus::CommandLineInterface::ProcessArgs(state, argc, argv); | ||
return EnergyPlusPgm(state); | ||
state->dataStrGlobals->VerStringVar = EnergyPlus::DataStringGlobals::VerString + "," + state->dataStrGlobals->CurrentDateTime; | ||
EnergyPlus::CommandLineInterface::ProcessArgs(*state, argc, argv); | ||
auto ep_ret = EnergyPlusPgm(*state); | ||
stateDelete(reinterpret_cast<EnergyPlusState>(state)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So is this actually necessary for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An intentional memory leak is actually still a memory leak. I don't love the stateDelete and casting shenanigans, but I'd prefer at least a comment if we remove them and rely on termination cleanup. |
||
return ep_ret; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed interesting. The elimination of global variable usage certainly cleaned up the possibility of having multiple copies all over the place, but I didn't imagine state itself would have been the culprit in this. I believe you, but will need to do some testing to also convince myself. Since you are calling the state API, you can also just use the
EnergyPlusState
typedef to round out the whole situation.