From 9b19e6ee3895a6aa7b805d4b5f1cd8b733f092ac Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Fri, 14 Oct 2016 09:42:50 -0700 Subject: [PATCH] Changing names and memory leak fix --- atom/browser/api/atom_api_window.cc | 10 +++++----- atom/browser/api/atom_api_window.h | 2 +- atom/browser/native_window.cc | 4 ++-- atom/browser/native_window.h | 4 ++-- atom/browser/native_window_mac.h | 2 +- atom/browser/native_window_mac.mm | 14 +++++++------- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 564c5392da5a..a0391985d7b3 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -729,12 +729,12 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) { window_->SetAspectRatio(aspect_ratio, extra_size); } -void Window::PreviewFile(const std::string& filepath, mate::Arguments* args) { - std::string filename; - if (!args->GetNext(&filename)) { - filename = filepath; +void Window::PreviewFile(const std::string& path, mate::Arguments* args) { + std::string fileName; + if (!args->GetNext(&fileName)) { + fileName = path; } - window_->PreviewFile(filepath, filename); + window_->PreviewFile(path, fileName); } void Window::SetParentWindow(v8::Local value, diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index a340b2c5e131..ba1a999b2b6b 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -170,7 +170,7 @@ class Window : public mate::TrackableObject, void SetMenuBarVisibility(bool visible); bool IsMenuBarVisible(); void SetAspectRatio(double aspect_ratio, mate::Arguments* args); - void PreviewFile(const std::string& filepath, mate::Arguments* args); + void PreviewFile(const std::string& path, mate::Arguments* args); void SetParentWindow(v8::Local value, mate::Arguments* args); v8::Local GetParentWindow() const; std::vector> GetChildWindows() const; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 140dd1e3b6f8..9d56615e6b2b 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -374,8 +374,8 @@ void NativeWindow::SetAspectRatio(double aspect_ratio, aspect_ratio_extraSize_ = extra_size; } -void NativeWindow::PreviewFile(const std::string& filepath, - const std::string& filename) { +void NativeWindow::PreviewFile(const std::string& path, + const std::string& fileName) { } void NativeWindow::RequestToClosePage() { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index e3b9fe563e7e..e3d1558cfa0d 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -176,8 +176,8 @@ class NativeWindow : public base::SupportsUserData, double GetAspectRatio(); gfx::Size GetAspectRatioExtraSize(); virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size); - virtual void PreviewFile(const std::string& filepath, - const std::string& filename); + virtual void PreviewFile(const std::string& path, + const std::string& fileName); base::WeakPtr GetWeakPtr() { return weak_factory_.GetWeakPtr(); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 9fc2627a0c87..1a6d2d382cd3 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -55,7 +55,7 @@ class NativeWindowMac : public NativeWindow, void SetMovable(bool movable) override; void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size) override; - void PreviewFile(const std::string& filepath, const std::string& filename) + void PreviewFile(const std::string& path, const std::string& fileName) override; bool IsMovable() override; void SetMinimizable(bool minimizable) override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 1a51f68a93c7..52e2111da307 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -492,9 +492,9 @@ bool ScopedDisableResize::disable_resize_ = false; return [self quickLookItem]; } -- (void)previewFileAtPath:(NSString *)filepath withName:(NSString *) name { - NSURL * url = [[NSURL alloc] initFileURLWithPath:filepath]; - [self setQuickLookItem:[[AtomPreviewItem alloc] initWithURL:url title:name]]; +- (void)previewFileAtPath:(NSString *)path withName:(NSString *) fileName { + NSURL * url = [[[NSURL alloc] initFileURLWithPath:path] autorelease]; + [self setQuickLookItem:[[[AtomPreviewItem alloc] initWithURL:url title:fileName] autorelease]]; [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil]; } @@ -953,11 +953,11 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio, [window_ setResizeIncrements:NSMakeSize(1.0, 1.0)]; } -void NativeWindowMac::PreviewFile(const std::string& filepath, const std::string& filename) { - NSString *path = [NSString stringWithUTF8String:filepath.c_str()]; - NSString *name = [NSString stringWithUTF8String:filename.c_str()]; +void NativeWindowMac::PreviewFile(const std::string& path, const std::string& fileName) { + NSString *pathStr = [NSString stringWithUTF8String:path.c_str()]; + NSString *nameStr = [NSString stringWithUTF8String:fileName.c_str()]; - [window_ previewFileAtPath:path withName:name]; + [window_ previewFileAtPath:pathStr withName:nameStr]; } void NativeWindowMac::SetMovable(bool movable) {