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

Some changes about tabs #71

Merged
merged 14 commits into from Jan 9, 2020
Merged

Some changes about tabs #71

merged 14 commits into from Jan 9, 2020

Conversation

ouuan
Copy link
Member

@ouuan ouuan commented Jan 8, 2020

See the commit messages for more information.

Use the competitive companion logic introduced in 22af606 and 1b1058a (don't open new tabs).
Use AppWindow::openFile() for opening files.

Thus fix bug of opening files via command line arguments / drag & drop.

Duplicate files were not detected when opening via these two ways before.
@caretaker-claire
Copy link

Hi ouuan
Thank you for your contribution to cp-editor2. I will request a review from one of the contributor. Once they approves and all CI checks passes, I will merge your Pull Request.

Segment fault in the following situations are fixed:

1. all tabs are closed, apply settings in preference window

2. all tabs are closed, received a competitive companion request

After fixing, if all tabs are closed and a competitive companion
request is received, a new tab will be opened for it.
This is the same as many other text editors, for example, Sublime Text.

"Unsaved file" is a little confusing, it may be understood as "file with
unsaved changes".
@ouuan
Copy link
Member Author

ouuan commented Jan 9, 2020

I'm solving a segmentation fault introduced in 358c3fe, please wait before merge.

@ouuan
Copy link
Member Author

ouuan commented Jan 9, 2020

To reproduce the segmentation fault:

  1. open the editor
  2. open a new tab (then there are two tabs, and the current tab is the second one)
  3. close the first tab

If you switch to the first tab and close the second one, everything works well.

Deleting https://github.com/coder3101/cp-editor/blob/358c3feaacff46b1807f0697dd7526b1fb9a245b/src/appwindow.cpp#L230 will solve this segmentation fault (but I can't delete it). But calling tmp->disconnect() before closing it won't solve this segmentation fault.

Do you have ideas on how to solve this?

@ouuan
Copy link
Member Author

ouuan commented Jan 9, 2020

I think I got the reason, switch to a tab will cause a editorTextChanged, and the windowIndex has not been updated yet.

To reproduce the segmentation fault:

1. open the editor
2. open a new tab (then there are two tabs, and the current tab is the second one)
3. close the first tab

If you switch to the first tab and close the second one, everything works well.

It's caused by not updated windowIndex.

It's fixed by updating windowsIndex in onTabChanged().
Copy link
Member

@coder3101 coder3101 left a comment

Choose a reason for hiding this comment

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

Should I merge it now?

@ouuan
Copy link
Member Author

ouuan commented Jan 9, 2020

OK, you can merge it.

@coder3101 coder3101 merged commit 3fa4eb0 into cpeditor:master Jan 9, 2020
@ouuan ouuan deleted the tabs branch January 9, 2020 08:16
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.

None yet

2 participants