-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
add warning when addTabbedWindow is called on self #12059
Conversation
atom/browser/native_window_mac.mm
Outdated
if ([window_ respondsToSelector:@selector(addTabbedWindow:ordered:)]) { | ||
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove]; | ||
if (window_.get() == window->GetNativeWindow()) { | ||
NSLog(@"Error: AddTabbedWindow cannot be called by a window on itself."); |
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 doesn't go over JS logs, can we do ThrowError
instead (pass in mate::arguments
or something)
window_->AddTabbedWindow(window); | ||
void BrowserWindow::AddTabbedWindow(NativeWindow* window, | ||
mate::Arguments* args) { | ||
window_->AddTabbedWindow(window, args); |
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.
We shouldn't be processing/using native-mate
outside the api layer, can you instead change the signature of NativeWindow::AddTabbedWindow
to have a return value and throw error in api::BrowserWindow
? Thanks!
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.
on it!
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.
LGTM, with minor changes. Thanks!
atom/browser/native_window_mac.mm
Outdated
@@ -918,6 +918,7 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val, | |||
} | |||
|
|||
if (transparent()) { | |||
NSLog(@"Setting transparent"); |
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.
I believe this is not related to the PR.
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.
Woops, had that in my staged env 🏃
void BrowserWindow::AddTabbedWindow(NativeWindow* window) { | ||
window_->AddTabbedWindow(window); | ||
void BrowserWindow::AddTabbedWindow(NativeWindow* window, | ||
mate::Arguments* args) { |
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.
Can you run clang-format
to fix style issue.
add warning when addTabbedWindow is called on self (cherry picked from commit dfa1dc4)
add warning when addTabbedWindow is called on self (cherry picked from commit dfa1dc4)
Merge pull request #12059 from electron/add-tabbedwindow-warning
Closes #12046.
Per documentation, you can't add a tabbed window with the same window; you need to create a new one. When you add a new window, you need to pass in a value for
NSWindowOrderingMode
, which can be onlyNSWindowAbove
,NSWindowBelow
, orNSWindowOut
. As you can't set a window above or below itself, this will crash it.This PR catches attempts to do the above and instead outputs an error explaining that it must be called on a new window.
/cc @bpasero @MarshallOfSound