Browse Source

Changing names and memory leak fix

Pierre Laurac 8 years ago
parent
commit
9b19e6ee38

+ 5 - 5
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<v8::Value> value,

+ 1 - 1
atom/browser/api/atom_api_window.h

@@ -170,7 +170,7 @@ class Window : public mate::TrackableObject<Window>,
   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<v8::Value> value, mate::Arguments* args);
   v8::Local<v8::Value> GetParentWindow() const;
   std::vector<v8::Local<v8::Object>> GetChildWindows() const;

+ 2 - 2
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() {

+ 2 - 2
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<NativeWindow> GetWeakPtr() {
     return weak_factory_.GetWeakPtr();

+ 1 - 1
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;

+ 7 - 7
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) {