Skip to content

Commit

Permalink
Fix crash on Windows 8 upon displaying certain files' timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom94 committed Jan 30, 2022
1 parent 4d2878c commit 00fe932
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,11 @@ void Image::updateChannel(const string& channelName, int x, int y, int width, in

template <typename T>
time_t to_time_t(T timePoint) {
// TODO: clean up this mess once all compilers support clock_cast.
#ifdef _WIN32
return chrono::system_clock::to_time_t(chrono::clock_cast<chrono::system_clock>(timePoint));
#elif __APPLE__
// `clock_cast` appears to throw errors on some systems, so we're using this slightly hacky
// inaccurate/random time conversion (now() is not called simultaneously for both clocks)
// in order to convert to system time.
using namespace chrono;
return system_clock::to_time_t(time_point_cast<system_clock::duration>(timePoint - T::clock::now() + system_clock::now()));
#else
return chrono::system_clock::to_time_t(T::clock::to_sys(timePoint));
#endif
}

string Image::toString() const {
Expand Down

0 comments on commit 00fe932

Please sign in to comment.