This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 234795 - Multiple tabs with the same code
Summary: Multiple tabs with the same code
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 7.3.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: igor_nikiforov
URL:
Keywords: 7.4_HR_FIX
Depends on:
Blocks: 230126
  Show dependency tree
 
Reported: 2013-08-22 13:21 UTC by DrSobik
Modified: 2013-11-12 12:38 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (42.84 KB, text/plain)
2013-08-22 13:21 UTC, DrSobik
Details
IDE log (51.73 KB, text/plain)
2013-09-05 12:05 UTC, DrSobik
Details
Proposed patch (5.76 KB, patch)
2013-09-06 14:58 UTC, Andrew Krasny
Details | Diff
Proposed patch (4.19 KB, patch)
2013-09-06 21:09 UTC, Andrew Krasny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description DrSobik 2013-08-22 13:21:30 UTC
Dear Developers,

I am using NetBeans IDE intensively for developing with C++ and Qt. In the last several releases of the IDE I am experiencing an unexpected behavior considering the tabs with different code files.
I will try to explain it using the following example. Suppose we have two files Test.h and Test.cpp and some class Test defined in them. The class has some method void proc(). If I open a tab with Test.h and CTRL+click on the declaration of the method, a tab with file Test.cpp opens and I am able to view the implementation of the method. So far so good and works as expected. Assume that there is some mistake in the code within the method. Then the compiler tells me that it has encountered an error at this place and provides me a link inside the Output window to the method where the error occurred. As soon as I click this link, an additional tab with Test.cpp is opened. Exactly an ADDITIONAL, since now I have two tabs corresponding to Test.cpp.This happens very frequently especially in large projects. An expected behavior would be that the already opened tab for Test.cpp is reopened and not that a new identical tab is created. This issue has been bothering me for some time within several last releases of NetBeans IDE. I hope, you will be able to reproduce the problem and fix it.

Best regards,

Oleh Sobeyko



Product Version = NetBeans IDE 7.3.1 (Build 201306052037)
Operating System = Linux version 3.7.10-1.16-desktop running on amd64
Java; VM; Vendor = 1.7.0_40
Runtime = OpenJDK 64-Bit Server VM 24.0-b50
Comment 1 DrSobik 2013-08-22 13:21:38 UTC
Created attachment 139067 [details]
IDE log
Comment 2 Vladimir Voskresensky 2013-08-23 14:49:39 UTC
Please, try recent 7.4 bits and verify if problem is solved.

*** This bug has been marked as a duplicate of bug 230126 ***
Comment 3 DrSobik 2013-08-23 19:28:03 UTC
(In reply to Vladimir Voskresensky from comment #2)
> Please, try recent 7.4 bits and verify if problem is solved.
> 
> *** This bug has been marked as a duplicate of bug 230126 ***

I have downloaded the latest NB 7.4 beta for C++. The problem persists. I opened a file Test.h from the Projects window. Then I CTRL+clicked on the constructor method Test(). A file Test.cpp has opened. Then I CTRL+click the method in Test.cpp. Unfortunately, an additional tab for Test.h opens. Thus, I have two tabs for Test.h and one for Test.cpp.

Kind regards,

Oleh Sobeyko
Comment 4 Vladimir Voskresensky 2013-08-26 07:25:17 UTC
Oleh, it is not in Beta, but in the latest daily build.
Please, try http://bits.netbeans.org/download/trunk/nightly/latest/

Thanks!
Vladimir

*** This bug has been marked as a duplicate of bug 230126 ***
Comment 5 DrSobik 2013-09-04 17:26:38 UTC
Hello guys,

sorry for a small delay. I've just checked with the nightly build NetBeans IDE Dev (Build 201309040001). I made a fresh installation without importing any additional settings from the other NB versions. The problem still persists. As soon as there is a bug in my source code and I click the corresponding link in the output window, I get two identical tabs of the same .cpp file opened.

Regards,

Oleh
Comment 6 DrSobik 2013-09-04 21:07:38 UTC
I am not sure but the cause of the problem might be the following. My project is located in some directory (ex. "/some_disk/projects_dir/"). Under my home directory, there is a system link to the project's directory (ex. "/home/user/link_to_the_projects_folder" points to "/some_disk/projects_dir/"). Usually I open the project through this link. I guess, the problem is that the link to the file in the output window is interpreted as an absolute path (i.e., "/some_disk/projects_dir/test.cpp") and not as the path over the FS link ("/home/user/link_to_the_projects_folder/test.cpp"). Thus, the editor is confused since there are two "different" paths, although they actually point to the same file. As a consequence, two tabs for the same file are opened.
Comment 7 igor_nikiforov 2013-09-05 11:20:58 UTC
I've tried the following scenario, and everything is working for me as expected:

1. Create Welcome sample in /tmp/111
2. Create symbolic link to above project in /tmp/222
3. Open both project from /tmp/111 and /tmp/222.
4. Click on welcome.cc from Welcome, located in /tmp/111 -> file is opened in editor.
5. Click on welcome.cc from Welcome, located in /tmp/2 -> no new file is opened in editor, but tab from item #4 is activated instead.

Is above scenario work for you?

If yes, could you please provide your own simple scenario so we can reproduce the issue.

Could you also attach new IDE log.

Regards,
  Igor
Comment 8 DrSobik 2013-09-05 12:00:18 UTC
OK. I've got it! You can reproduce the problem as follows:

1. Create a C++ project named "test" in /tmp/test. The main file is /tmp/test/main.cpp
2. Close the project in the IDE.
3. Create a link to the project's directory, i.e., /tmp/test_link points to /tmp/test
4. Open the project using the IDE: "File->Open Project" and select /tmp/test_link. The project opens. Pay attention: in the project's properties you will see a path "/tmp/test_link" and not "/tmp/test"!
5. Type some code with a mistake in the body of the main function.
6. Compile. The compiler gives a link to the error. Click on the link.
7. An additional tab for "main.cpp" is opened. Its path is "/tmp/test/main.cpp". The original tab has a path "/tmp/test_link/main.cpp".

Hopefully, you can reproduce the problem as I just did it several times.

Kind regards,

Oleh
Comment 9 DrSobik 2013-09-05 12:05:18 UTC
Created attachment 139699 [details]
IDE log
Comment 10 igor_nikiforov 2013-09-06 05:36:40 UTC
Thanks for test case. Now we are able to reproduce the issue.
Comment 11 Andrew Krasny 2013-09-06 14:57:16 UTC
The cause is clear.
The problem is that OutputListenerImpl (cnd), when parses the output of a compiler, creates FileObject using a full path. Later, when user clicks on a hyperlink, NB infrastructure tries to open an editor at a specific line. 
At this moment CESRedirector works, but COSRedirector is not involved. So we get a described situation.

It would be good to have a fix in the infrastructure. But there is a problem of non-public APIs.. There is a possible solution (that doesn't require clients modifications), but it requires some reflection ;( 
Attached... 

Any better suggestions?
Comment 12 Andrew Krasny 2013-09-06 14:58:07 UTC
Created attachment 139766 [details]
Proposed patch
Comment 13 Vladimir Voskresensky 2013-09-06 15:04:32 UTC
Mila, Jarda, please, have a look at proposed patch in EditorSupportLineSet.java. Is it OK?
Comment 14 Andrew Krasny 2013-09-06 21:09:01 UTC
Created attachment 139779 [details]
Proposed patch
Comment 15 assylias 2013-09-06 22:32:10 UTC
I encountered a similar issue with a pom.xml (maven) file. It was opened twice (and I had not realised). Changes to one of the files were automatically reverted every time I tried to clean and build the project or run mvn install.
Closing one of the two tabs solved the issue.

Hopefully the patch you submitted will fix this too.
Comment 16 Vladimir Voskresensky 2013-09-11 20:02:20 UTC
We needed that to be fixed in 7.4, right?

If no one objects to Andrew's patch, please, finish HR process.

Thanks.
Comment 17 soldatov 2013-09-12 12:52:51 UTC
verified in build with fix

Scenario from comment 8 is fixed.
Comment 18 igor_nikiforov 2013-09-12 14:15:10 UTC
The fix is integrated to releases:
  http://hg.netbeans.org/releases/rev/192d03ebe66f
Comment 19 Miloslav Metelka 2013-09-15 22:05:06 UTC
So I assume that this is just a temporary fix and the reflection will get removed once appropriate API gets created. So we need to add smtg like

public static CloneableOpenSupport findRedirect(CloneableOpenSupport)

to CloneableOpenSupport? Probably Jarda should resolve what would be optimal.

Personally I'm not a big fan of the redirects since I've seen them in several profiler snapshots as being rather slow but calls to SupportLine.show() should not be frequent (not sure though regarding getDisplayName()).
Comment 20 Quality Engineering 2013-09-16 02:01:07 UTC
Integrated into 'main-silver', will be available in build *201309160002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/21f0d9fe2d25
User: Alexander Simon <alexvsimon@netbeans.org>
Log: Bug #234795 - Multiple tabs with the same code
(transplanted from 39498e613c11ec978dc75482efa71623ea259a52)
Comment 21 DrSobik 2013-09-17 19:12:04 UTC
Hello guys,

I've just tested the latest build (Build 201309170002). It seems that the problem still persists. Has the patch already been integrated into this version?

Regards,

Oleh
Comment 22 DrSobik 2013-10-02 07:06:38 UTC
I've just tested the latest NB 7.4 RC2. The problem still persists (see Comment 8 for reproduction steps).

Kind regards,

Oleh
Comment 23 igor_nikiforov 2013-10-04 09:35:21 UTC
I've tried both scenarios from Comment 7 and Comment 8, and both of them works for me in NetBeans 7.4 RC 2.

Just in case here are my very detailed steps:

1. Start NetBeans 7.4 RC 2 with fresh user directory.
2. Create Welcome sample in /tmp/111.
3. Make some error in welcome.cc, try to build project and check that link to error is available int the Output.
4. Close project and close IDE.
5. Create link /tmp/222/Welcome to /tmp/111/Welcome.
6. Start IDE with the same user directory and open /tmp/222/Welcome project.
7. Build it and click the compilation error link in the Output -> welcome.cc editor appears.
8. Open project /tmp/111/Welcome.
9. Build it and click the error link in the Output -> welcome.cc editor becomes active, no new editor appears.
10. Try to click on welcome.cc node in Project View from both /tmp/222/Welcome and /tmp/111/Welcome -> no new editor appears.

Does these steps work for you? Probably something is missed from my test case?

Downgrading this to P3 and setting to incomplete so far.
Comment 24 DrSobik 2013-10-04 10:53:22 UTC
Hello Igor,

considering Comment 23, everything works fine if I do it as you described. But I get the problem again when I perform the following steps:

1. Start NetBeans 7.4 RC 2 with fresh user directory.
2. Create Welcome sample in /tmp/111.
3. Make some error in welcome.cpp, try to build the project and check that link to error is available int the Output.
4. Close project and close IDE.
5. Create link /tmp/222/Welcome to /tmp/111/Welcome.
6. Start IDE with the same user directory and open /tmp/222/Welcome project.

7. Open the welcome.cpp (its path in the editor /tmp/222/Welcome/welcome.cpp) file of the project (the code contains the error).
8. Run build with the error. Don't touch the link in the output window!
9. Remove the error and build again. Should compile without problems.
10. Type in the error code again and run build. The compiler provides an error link in the output window.
11. Click on the link. A new tab opens with welcome.cpp (its path in the editor is /tmp/111/Welcome/welcome.cpp)

Interesting is that this problem occurs again "every once a while" now. I have tried this about 5 times and in two cases I did reproduce the error.

Regards,

Oleh
Comment 25 igor_nikiforov 2013-10-04 12:13:25 UTC
Thanks for such a quick response!

I've managed to reproduce that and will investigate the reason.

Regards,
 Igor
Comment 26 igor_nikiforov 2013-10-07 10:08:21 UTC
The issue is resolved in internal repo:
  rev/1858edaca92c
Comment 27 Quality Engineering 2013-10-11 02:23:08 UTC
Integrated into 'main-silver', will be available in build *201310110001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/c20015b42546
User: Igor Nikiforov <igor_nikiforov@netbeans.org>
Log: Bug 234795 - Multiple tabs with the same code - additional fix.
(transplanted from 1858edaca92cdd94ecdcef43adf7fd01ff994a88)
Comment 28 DrSobik 2013-10-11 09:02:48 UTC
Hello Igor,

I've just tested the latest build. The problems seems to be gone :) I'll do some more testing. If I find anything I'll let you know.

Best regards,

Oleh
Comment 29 DrSobik 2013-10-18 08:47:03 UTC
Just installed the latest NB 7.4. The problems appeared again :( ( see Comment 8 ). But the issue seems to be fixed in build 201310110001 . Has the fix been integrated into the final 7.4 ?

Regards,

Oleh
Comment 30 Marian Mirilovic 2013-10-18 08:50:52 UTC
The additional fix from  Comment 27 didn't go into 7.4, Igor please clarify ...
Comment 31 DrSobik 2013-11-04 10:42:22 UTC
Still no reaction and no changes... I'm currently using build 201310110001, since the problem is fixed there. Please, add this fix to the final NB 7.4 or to NB 7.4.1, in case it id going to be provided.

Regards,

Oleh
Comment 32 Vladimir Voskresensky 2013-11-05 00:04:04 UTC
Oleh, you are right. 7.4 doesn't contain the fix, it is only fixed in trunk, but nominated for the upcoming 7.4 update.
Comment 33 Vladimir Voskresensky 2013-11-05 00:06:21 UTC
Could you verify current trunk version, please.
Thanks for your support!
Comment 34 DrSobik 2013-11-05 09:29:39 UTC
In the nightly build 201311050001, the problem seems to be resolved.

Regards,

Oleh
Comment 35 Vladimir Voskresensky 2013-11-05 15:04:49 UTC
great. should be integrated soon in 7.4 patch
Comment 36 Quality Engineering 2013-11-11 20:16:12 UTC
Integrated into 'releases/release74', will be available in build *201311111738* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/89f89f2a50b6
User: igor_nikiforov <igor_nikiforov@netbeans.org>
Log: Bug 234795 - Multiple tabs with the same code - additional fix.
(transplanted from 1858edaca92cdd94ecdcef43adf7fd01ff994a88)