Bug 56429

Summary: Can't open two files with the same name (but from different directories) in the editor
Product: [Applications] kdevelop Reporter: Amilcar do Carmo Lucas <a.lucas>
Component: generalAssignee: KDevelop Developers <kdevelop-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Amilcar do Carmo Lucas 2003-03-26 10:35:05 UTC
Version:            (using KDE KDE 3.1)
Installed from:    SuSE RPMs
OS:          Linux

As soon as you click on the second file on the file tree view, the focus goes to the file already opened.

So if you're distracted you start editing this file without realizing that this isn't the file you want to edit. :(

-It should either open the second file (the full path of the current file is already being displayed ton the window titlebar, so if you look there yo can see which file you're dealing with)

or

-Give you an error message and tell you that it canot open the second file before you close the first
Comment 1 Amilcar do Carmo Lucas 2003-04-07 14:30:03 UTC
Just to confirm this bug on today's cvs. 
Comment 2 Hamish Rodda 2003-04-07 14:41:21 UTC
Subject: kdevelop/src

CVS commit by rodda: 

Fix bug 56429: unable to open files with same name in different directories.

CCMAIL:56429-done@bugs.kde.org


  M +11 -6     partcontroller.cpp   1.76


--- kdevelop/src/partcontroller.cpp  #1.75:1.76
@@ -157,9 +157,12 @@ void PartController::setEncoding(const Q
 void PartController::editDocument(const KURL &inputUrl, int lineNum)
 {
+  kdDebug(9000) << k_funcinfo << inputUrl.prettyURL() << " linenum " << lineNum << endl;
+
   KURL url = inputUrl;
   bool localUrl = url.url().startsWith("file:/");
 
   // Make sure the URL exists
-  if (!url.isValid() || (!localUrl && !KIO::NetAccess::exists(url))) {
+  // KDE 3.0 compatibility hack: use KIO::NetAccess for everything >= KDE 3.1
+  if (!url.isValid() || (localUrl ? !QFile(url.path()).exists() : !KIO::NetAccess::exists(url))) {
     // Try to find this file in the current project's list instead
     KDevProject* project = API::getInstance()->project();
@@ -178,5 +181,5 @@ void PartController::editDocument(const 
 
     localUrl = url.url().startsWith("file:/");
-    if (!url.isValid() || (!localUrl && !KIO::NetAccess::exists(url))) {
+    if (!url.isValid() || (localUrl ? !QFile(url.path()).exists() : !KIO::NetAccess::exists(url))) {
       // See if this url is relative to the current project's directory
       url = project->projectDirectory() + "/" + url.url();
@@ -184,5 +187,5 @@ void PartController::editDocument(const 
 
     localUrl = url.url().startsWith("file:/");
-    if (!url.isValid() || (!localUrl && !KIO::NetAccess::exists(url))) {
+    if (!url.isValid() || (localUrl ? !QFile(url.path()).exists() : !KIO::NetAccess::exists(url))) {
       // Here perhaps we should prompt the user to find the file?
       return;
@@ -190,4 +193,6 @@ void PartController::editDocument(const 
   }
 
+  // We now have a url that exists ;)
+
   url.cleanPath(true);
 
@@ -390,5 +395,5 @@ QPopupMenu *PartController::contextPopup
 
 
-static bool urlIsEqual(const KURL &a, const KURL &b)
+/*static bool urlIsEqual(const KURL &a, const KURL &b)
 {
   if (a.isLocalFile() && b.isLocalFile())
@@ -404,5 +409,5 @@ static bool urlIsEqual(const KURL &a, co
 
   return a == b;
-}
+}*/
 
 KParts::Part *PartController::partForURL(const KURL &url)
@@ -412,5 +417,5 @@ KParts::Part *PartController::partForURL
   {
     KParts::ReadOnlyPart *ro_part = dynamic_cast<KParts::ReadOnlyPart*>(it.current());
-    if (ro_part && urlIsEqual(url, ro_part->url()))
+    if (ro_part && url == ro_part->url())
       return ro_part;
   }