Skip to content
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

Merged
merged 6 commits into from
Feb 28, 2018

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Feb 26, 2018

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 only NSWindowAbove, NSWindowBelow, or NSWindowOut. 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

@codebytere codebytere requested a review from a team February 26, 2018 22:50
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.");
Copy link
Member

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);
Copy link
Member

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!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on it!

@jkleinsc jkleinsc closed this Feb 27, 2018
@jkleinsc jkleinsc reopened this Feb 27, 2018
Copy link
Member

@deepak1556 deepak1556 left a 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!

@@ -918,6 +918,7 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
}

if (transparent()) {
NSLog(@"Setting transparent");
Copy link
Member

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.

Copy link
Member

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) {
Copy link
Member

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.

@codebytere codebytere merged commit dfa1dc4 into master Feb 28, 2018
@codebytere codebytere deleted the add-tabbedwindow-warning branch February 28, 2018 09:18
alexeykuzmin pushed a commit that referenced this pull request Mar 8, 2018
add warning when addTabbedWindow is called on self

(cherry picked from commit dfa1dc4)
alexeykuzmin pushed a commit that referenced this pull request Mar 8, 2018
add warning when addTabbedWindow is called on self

(cherry picked from commit dfa1dc4)
alexeykuzmin added a commit that referenced this pull request Mar 8, 2018
Merge pull request #12059 from electron/add-tabbedwindow-warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants