Bug report #11399

Unable to add raster and vector files via drag and drop on OS X 10.10

Added by david dellatore over 9 years ago. Updated over 8 years ago.

Status:Closed
Priority:Normal
Assignee:Larry Shaffer
Category:Browser
Affected QGIS version:2.4.0 Regression?:No
Operating System:OSX, WIN8.1 Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:19681

Description

I have a clean install of OSx Yosemite Beta 5, with homebrew install of QGIS 2.4 and all its basic dependencies.

-QGIS version 2.4.0-Chugiak
-QGIS code revision exported -Compiled against Qt 4.8.6
-Running against Qt 4.8.6 -Compiled against GDAL/OGR 1.11.1
-Running against GDAL/OGR 1.11.1 -Compiled against GEOS 3.4.2-CAPI-1.8.2
-Running against GEOS 3.4.2-CAPI-1.8.2 r3921 -PostgreSQL Client Version 9.3.5
-SpatiaLite Version 4.2.0 -QWT Version 6.1.1
-PROJ.4 Version 480 -QScintilla2 Version 2.8.3

Am able to load QGIS with no errors thrown, and can view shapefiles, connect to postgres, etc, but can only add new shapefiles if done through the 'Layer - Add Vector Layer' workflow. Dragging and dropping into QGIS results in:

'Invalid Data Source:/.file/id=6571367..... is not a valid or recognized data source

I am also unable to use SPIT to import shapefiles into postgres:

Problem inserting features from file:/xxxxx/xx.shp

Am trying to migrate from just using arcgis, so any help would be greatly appreciated.

This was reported by another user in August 2014 (https://gis.stackexchange.com/questions/111668/qgis-2-4-0-mac-yosemite-compatibility), and is still an issue now.

Thank you

Screen_Shot_2014-10-19_at_13.15.36.png (165 KB) david dellatore, 2014-10-19 04:18 AM

Associated revisions

Revision 220affbf
Added by Larry Shaffer over 8 years ago

Fix #11399; fix up Mac OS X 10.10+ dropped file URLs

History

#1 Updated by Anita Graser over 9 years ago

The path to the file looks very fishy, especially with the = sign ...

/.file/id=6571367

Have you tried moving the files to a clean path like /home/temp?

#2 Updated by david dellatore over 9 years ago

Greetings and thank you for the response.

I have tried moving files (which were in dropbox folder) to the desktop, to my home directory, and to /home/public, all with the same result with drag/drop:

Invalid Data Source: /.file/id=6571367.3678663 is not a valid or recognized data source

However when double clicking the same .shp from the finder, the files open up fine in QGIS - so that the functionality is partly there, but still something missing.

The path to the file looks very fishy, especially with the = sign ...

/.file/id=6571367

Have you tried moving the files to a clean path like /home/temp?

#3 Updated by david dellatore over 9 years ago

Just for info - have tried installing qgis-22, and the same error remains. Have attached a screenshot for context.

#4 Updated by John Tull over 9 years ago

This issue exists in trunk also. It has been present for some time. I was just looking to post a bug report, but this bug covers it.

To summarize, the browser in qgis works fine for adding files. Double-clicking a shapefile in the Finder will add it to qgis. Using the 'Add vector layer...' menu item and browsing to your file will work. Dragging a shapefile (or any suitable raster or vector layer) results in an error, "Invalid data source ...".

My OS X version is 10.10, had the problem during beta testing of 10.10 also. I do not recall if this issue existed on 10.9.

#5 Updated by John Tull over 9 years ago

  • Target version set to Version 2.6
  • Operating System set to OSX

#6 Updated by Jürgen Fischer over 9 years ago

  • Target version changed from Version 2.6 to Future Release - High Priority

#7 Updated by John Tull over 9 years ago

  • Subject changed from Unable to add shapefiles via drag and drop to Unable to add raster and vector files via drag and drop on OS X 10.10

I updated the title of this bug to properly reflect the greater issue, i.e., the inability to load both vector and raster files via drag and drop on OS X 10.10. If others with older OS versions can confirm this issue is not specific to Yosemite (10.10), please update the title.

Here is further information on this as it has been documented in the Qt bug tracker:
https://bugreports.qt-project.org/browse/QTBUG-40449

Perhaps a solution lies therein?

#8 Updated by Benoit de Cabissole over 9 years ago

  • Operating System changed from OSX to OSX, WIN8.1

Also happens on Dev. versions since at least beginning of December 2014, on Windows 8.1.

#9 Updated by Larry Shaffer almost 9 years ago

Hi,

This can be fixed for Qt 4.8.x, but requires direct access to the Cocoa API when needed to introduce the workarounds noted in the QTBUG-40449.

Btw, this is an example of my old PR to introduce abstracted calls to the OS (Mac for example, with Objective-C++) to handle changes in OS API libraries and keep such workarounds in one place instead of peppered throughout the source tree.

I suppose the same could be done for Win as well.

#10 Updated by John Tull over 8 years ago

The references qt bug has a comment from Aug 2015 with the following workaround code that should work with recent qt4. Perhaps this can be worked into qgis code to fix this issue that is quite the show-stopper on OS X:

  QString localFileQString = url.toLocalFile();
      // [pzion 20150805] Work around
      // https://bugreports.qt.io/browse/QTBUG-40449
      if ( localFileQString.startsWith("/.file/id=") )
      {
        CFStringRef relCFStringRef =
          CFStringCreateWithCString(
            kCFAllocatorDefault,
            localFileQString.toUtf8().constData(),
            kCFStringEncodingUTF8
            );
        CFURLRef relCFURL =
          CFURLCreateWithFileSystemPath(
            kCFAllocatorDefault,
            relCFStringRef,
            kCFURLPOSIXPathStyle,
            false // isDirectory
            );
        CFErrorRef error = 0;
        CFURLRef absCFURL =
          CFURLCreateFilePathURL(
            kCFAllocatorDefault,
            relCFURL,
            &error
            );
        if ( !error )
        {
          static const CFIndex maxAbsPathCStrBufLen = 4096;
          char absPathCStr[maxAbsPathCStrBufLen];
          if ( CFURLGetFileSystemRepresentation(
            absCFURL,
            true, // resolveAgainstBase
            reinterpret_cast<UInt8 *>( &absPathCStr[0] ),
            maxAbsPathCStrBufLen
            ) )
          {
            localFileQString = QString( absPathCStr );
          }
        }
        CFRelease( absCFURL );
        CFRelease( relCFURL );
        CFRelease( relCFStringRef );
      }

#11 Updated by Larry Shaffer over 8 years ago

  • Assignee set to Larry Shaffer

#12 Updated by Larry Shaffer over 8 years ago

Hi John,

Have you verified that the fix you note works for OS X 10.10?

#13 Updated by John Tull over 8 years ago

Hi Larry,

No, I don't have the coding skills to apply this to qgis code. I was hoping someone else would come up with a way to implement this workaround and we could test from there.

#14 Updated by Larry Shaffer over 8 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF