Skip to content

Commit

Permalink
Fix memory leak where the NativeDialogs impl wasn't freed
Browse files Browse the repository at this point in the history
This is because the new NativeDialogsImpl starts with one reference,
and the Ref::reset(T*) adds another reference.
  • Loading branch information
dacap committed Jul 19, 2023
1 parent 5d81c8a commit 5fcfcf3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions os/common/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class CommonSystem : public System {
NativeDialogs* nativeDialogs() override {
if (!m_nativeDialogs) {
#if LAF_WINDOWS
m_nativeDialogs.reset(new NativeDialogsWin);
m_nativeDialogs = Ref<NativeDialogs>(new NativeDialogsWin);
#elif LAF_MACOS
m_nativeDialogs.reset(new NativeDialogsOSX);
m_nativeDialogs = Ref<NativeDialogs>(new NativeDialogsOSX);
#elif LAF_LINUX
m_nativeDialogs.reset(new NativeDialogsX11);
m_nativeDialogs = Ref<NativeDialogs>(new NativeDialogsX11);
#endif
}
return m_nativeDialogs.get();
Expand Down

0 comments on commit 5fcfcf3

Please sign in to comment.