Bug 140161

Summary: Jump to error (from the ouput "Messages" window) does NOT open the corresponding file
Product: [Applications] kdevelop Reporter: Achim Spangler <Achim.Spangler>
Component: generalAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Patch which solves the JumpToError problem for me

Description Achim Spangler 2007-01-16 16:31:22 UTC
Version:           SVN RC2 3.3.94 from REPO state 16.01.2007 (using KDE KDE 3.5.5)
Installed from:    Ubuntu Packages
Compiler:          gcc 4.1 
OS:                Linux

There are already several comparable errors registrated in Bugzilla. But the best matching entries are already defined as RESOLVED, so that I open a new report - as I'm using the most current SVN Repo state 624075 (16.01.2007).

Important:
The most current STABLE Kdevelop Kubuntu Package WORKS in the given project setup!!
(same .kdevelop project file opened with stable Kdevelop in same directory with same sources, ... --> I do not want anything new here).

Project setup:
The project files are located in a subdirectory:
compiler_projects/kdevelop/proj1: <<-- Makefile and .kdevelop files are located here
xgpl_src/.... <<-- (most) sources are located here

I found two problems in src/partcontroller.cpp
a) line 291 and 298 did NOT use relURL for call of KIO::NetAccess::exists(), so that the
    CORRECT absolute filename in relURL has not been used
    --> change if (relURL.isValid() && KIO::NetAccess::exists(url, false, 0))
          to if (relURL.isValid() && KIO::NetAccess::exists(relURL, false, 0))
    SOLVES first part of the problem

b) Partial path concatentation with KURL works strange in my case.
    I am used (this works with Kdevelop-3.3.x) to set 
  <projectdirectory>.</projectdirectory>
  <globalcwd>.</globalcwd>
  <builddir>.</builddir>
  as I want to avoid absolute pathes as far as possible.
  But this leads to the following debug output in PartController::editDocumentInternal()
kdevelop: [void PartController::editDocumentInternal(const KURL&, int, int, bool, bool)] Looking for file in project dir: /home/spangler/Projekte/IsoAgLib/compiler_projects/kdevelop_qmake/3_2_VirtualTerminalMultiIso url ./../../../xgpl_src/IsoAgLib/comm/ISO_Terminal/ext/impl/vtobjectsoftkeymaskconnector_c.h transformed to file:///home/spangler/Projekte/xgpl_src/IsoAgLib/comm/ISO_Terminal/ext/impl/vtobjectsoftkeymaskconnector_c.h: false
kdevelop: [void PartController::editDocumentInternal(const KURL&, int, int, bool, bool)] Looking for file in build dir: . url ./../../../xgpl_src/IsoAgLib/comm/ISO_Terminal/ext/impl/vtobjectsoftkeymaskconnector_c.h transformed to ../../../../xgpl_src/IsoAgLib/comm/ISO_Terminal/ext/impl/vtobjectsoftkeymaskconnector_c.h: false

  ==>>
  The url "./../../../xgpl_src/IsoAgLib/comm/ISO_Terminal/ext/impl/vtobjectsoftkeymaskconnector_c.h" is VALID when I change in konsole to the build directory (.kdevelop files are located in SAME folder). The leading "./" is exchanged with "../" during the concatenating constructor of KURL. At least the retrieved absolute path is missing ONE directory level.

When I change the above mentioned project directory settings to:
  <projectdirectory>./</projectdirectory>
  <globalcwd>./</globalcwd>
  <builddir>./</builddir>

The opening of files WORKS!!!

The Manual of KURL constructors seem to indicate, that the constructor is not meant to be used as done in the module. I changed it to add the relative path after construction with "addPath" - and voila IT WORKS now also with the project paths ".".
I'll attach a diff with all needed changes to get it working properly for me.
Please evaluate and merge the patch.

Bye,
Achim
Comment 1 Achim Spangler 2007-01-16 16:32:48 UTC
Created attachment 19304 [details]
Patch which solves the JumpToError problem for me

I hope that this patch is reasonable and can be merged.

Bye,
Achim
Comment 2 Jens Dagerbo 2007-01-16 16:49:25 UTC
I haven't tested yet, but both changes look correct. KURL::addPath() definitely should be used, and checking KIO::NetAccess::exists() against the partial url is clearly wrong.
Comment 3 Jens Dagerbo 2007-01-16 21:36:56 UTC
SVN commit 624237 by dagerbo:

Fix partial url lookup. Thanks to Achim Spangler for the patch!

BUG: 140161

 M  +6 -4      partcontroller.cpp  


--- branches/kdevelop/3.4/src/partcontroller.cpp #624236:624237
@@ -285,17 +285,19 @@
 		if ( API::getInstance()->project() )
 		{
 			if (url.isRelativeURL(url.url())) {
-				KURL relURL(API::getInstance()->project()->projectDirectory(), url.url());
+				KURL relURL(API::getInstance()->project()->projectDirectory());
+				relURL.addPath( url.url() );
 
 				kdDebug() << k_funcinfo << "Looking for file in project dir: " << API::getInstance()->project()->projectDirectory() << " url " << url.url() << " transformed to " << relURL.url() << ": " << done << endl;
-				if (relURL.isValid() && KIO::NetAccess::exists(url, false, 0)) {
+				if (relURL.isValid() && KIO::NetAccess::exists(relURL, false, 0)) {
 					url = relURL;
 					done = true;
 				}
 				else {
-					KURL relURL(API::getInstance()->project()->buildDirectory(), url.url());
+					KURL relURL(API::getInstance()->project()->buildDirectory());
+					relURL.addPath( url.url() );
 					kdDebug() << k_funcinfo << "Looking for file in build dir: " << API::getInstance()->project()->buildDirectory() << " url " << url.url() << " transformed to " << relURL.url() << ": " << done << endl;
-					if (relURL.isValid() && KIO::NetAccess::exists(url, false, 0)) {
+					if (relURL.isValid() && KIO::NetAccess::exists(relURL, false, 0)) {
 						url = relURL;
 						done = true;
 					}
Comment 4 maciek gajewski 2007-04-29 10:08:03 UTC
I'm using KDevelop-3.4 from kubuntu feisty's packages. The jump-to error works only if the file is already open in editor. Otherwise - no success.
Still no success.
NOTE: I'm using 'c++ app/custom makefile' project type.
Sorry for being grumpy, but this bug was reported many many times during last years... Will this ever work?