Basic fix to get qbroswer.app working on Mac #197

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Member

dakcarto commented Jul 21, 2012

  • More specific bundling needs added to make it a first-class app on Mac (About dialog, etc.), but this fix makes it functional.
  • Different plist and simple icon were added to differentiate between QGIS and browser app.
  • Browser app renamed from qbrowser.app to QGIS Browser.app

Note: QGIS Browser.app is still located in QGIS.app/Contents/MacOS/bin. For ease of launching, make a symlink or Finder alias to it.

Basic fix to get qbroswer.app working on Mac.
- More specific bundling needs added to make it a first-class app on Mac (About dialog, etc.), but this fix makes it functional.
- Different plist and simple icon were added to differentiate between QGIS and browser app.
- Browser app renamed from qbrowser.app to QGIS Browser.app

Note: QGIS Browser.app is still located in QGIS.app/Contents/MacOS/bin. For ease of launching, make a symlink or Finder alias to it.
@@ -102,4 +103,7 @@ INSTALL (TARGETS qbrowser
)
IF (APPLE)
INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../${QGIS_FW_SUBDIR} \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app/Contents/Frameworks\")")
+ INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../${QGIS_PLUGIN_SUBDIR}/.. \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app/Contents/Plugins\")")
@kyngchaos

kyngchaos Jul 21, 2012

Contributor

browser doesn't use plugins, no need folder

@@ -102,4 +103,7 @@ INSTALL (TARGETS qbrowser
)
IF (APPLE)
INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../${QGIS_FW_SUBDIR} \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app/Contents/Frameworks\")")
+ INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../${QGIS_PLUGIN_SUBDIR}/.. \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app/Contents/Plugins\")")
+ INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../${QGIS_DATA_SUBDIR} \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app/Contents/Resources\")")
@kyngchaos

kyngchaos Jul 21, 2012

Contributor

created automatically already when installing empty qt.conf

@@ -102,4 +103,7 @@ INSTALL (TARGETS qbrowser
)
IF (APPLE)
INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../${QGIS_FW_SUBDIR} \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app/Contents/Frameworks\")")
+ INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../${QGIS_PLUGIN_SUBDIR}/.. \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app/Contents/Plugins\")")
+ INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../${QGIS_DATA_SUBDIR} \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app/Contents/Resources\")")
+ INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../../${QGIS_LIB_SUBDIR} \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app/Contents/MacOS/lib\")")
@kyngchaos

kyngchaos Jul 21, 2012

Contributor

browser doesn't have any other lib dependencies, no need for this nonstandard OSX app dir

@@ -30,4 +30,7 @@ IF (APPLE)
ENDIF (QGIS_MACAPP_BUNDLE_USER)
# tickle app bundle
INSTALL (CODE "EXECUTE_PROCESS(COMMAND touch \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/../../.\")")
+
+ # rename qbrowser
+ INSTALL (CODE "EXECUTE_PROCESS(COMMAND mv \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qbrowser.app\" \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/QGIS Browser.app\")")
@kyngchaos

kyngchaos Jul 21, 2012

Contributor

ideally, the qbrowser target should set the app bundle name. It is possible to change the OUTPUT_NAME, but this changes both the executable name and the bundle name. I'll have dig around to see if it's possible to have a separate executable name and bundle name. If not, then the CFBundleExecutable in the plist will have to match the OUTPUT_NAME used.

Member

dakcarto commented Jul 21, 2012

Hi William,

Each of those is necessary. The browser does not currently function.

Remove the Plugins symlink and the browser only browses folders and loads no providers. No files are shown in the browser tree and no metadata or preview of the files is shown.

Remove the MacOS lib symlink and the browser won't launch, because the qgis frameworks link to libs:
dyld: Library not loaded: @executable_path/lib/libqwt.dylib (first linked lib encountered)

Remove the Resources and the new icon would need to be added when the empty qt.conf is added. Also, I'm not sure any translations will be accessible.

Edit: this is how it looks when running:

https://dl.dropbox.com/u/4058089/qgis/qbrowser_mac.png

Contributor

kyngchaos commented Jul 21, 2012

Other than code comments, generally I think qbrowser should be outside the QGIS app bundle. But this would mean bundling copies of the qgis and Qt frameworks, and increasing the distribution size a lot.

I didn't see any obvious way in QGIS to start it, so it's basically unusable, unless an alias is made, as you say. This is easiest short term solution, and can be done in the installer package (and probably in the cmake installation, for those source builders).

Member

dakcarto commented Jul 21, 2012

Yes, I had a cmake command for making the alias via an osascript call, but instead moved that to my build script, because I thought it didn't belong in the source. This is what it looks like on my Mac:

https://dl.dropbox.com/u/4058089/qgis/app_icons.png

I use a symlink on my master builds, because they are backed-up to a DMG, where the symlink works (referencing the QGIS.app in the DMG), an alias still references my startup disk.

If you were to package this setup, I think the alias would be best, since it can be moved around by the user.

Member

dakcarto commented Jul 21, 2012

This was the cmake command I deleted from the end of mac/CMakeLists.txt:

INSTALL (CODE "EXECUTE_PROCESS(COMMAND osascript -e 'tell application "Finder" to make alias file to POSIX file "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/QGIS Browser.app" at POSIX file "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/"')")

Member

dakcarto commented Jul 21, 2012

Actually, I think I got an error with that cmake command. Here is what does work (from my build script):

        /usr/bin/osascript > /dev/null <<EOT
tell application "Finder"
    set srcPath to POSIX file "$APPTARGET/Contents/MacOS/bin/QGIS Browser.app" as string
    set trgtPath to POSIX file "$APPTARGETDIR" as string
    make new alias file to application file srcPath at folder trgtPath
end tell
EOT

It would need adapted to a similar cmake command, or maybe an AppleScript adding to the build directory.

Contributor

kyngchaos commented Jul 21, 2012

I would create the alias on installation, not package the alias ;)

Member

dakcarto commented Jul 21, 2012

OK. Is the icon OK. I just whipped something up, considering the next QGIS icon will result from a design contest. If it doesn't have a different icon, it's hard to distinguish on the Dock. Plus the generic app icon is kinda lame.

Contributor

kyngchaos commented Jul 22, 2012

I took care of this, and a couple other updates, in #3c1c229.

I used the OUTPUT_NAME method for naming the app.

I figured out the osascript command - it needed double-escaping of the quotes to make it through the Cmake INSTALL(CODE) command.

Icon is probably OK for now. Needs discussion and coordination so other platforms have an icon.

@kyngchaos kyngchaos closed this Jul 22, 2012

Member

dakcarto commented Jul 22, 2012

William,

Not sure why you chose to ignore my testing and comments on this and close the request. Your fix, while adding the icon and alias, does not actually make the browser work.

To allow the browser to work, it needs access to the the Plugins folder, as per my symlink. Otherwise there are no providers loaded, and only folders get browsed.

Without the symlink to the QGIS Resources folder, no translations are available for the browser. There is no reason to create a separate Resources folder.

Contributor

kyngchaos commented Jul 22, 2012

sorry, I'm not very good at testing, and only ran the program and quit.

I missed the providers angle, but then it should be a link to "qgis" inside the plugins folder, unless there is more in the Qt plugin subfolders that the browser could use.

Resources really should be specific to an application. Maybe the browser string translations need to be split into their own file. Though there is probably a lot shared from the frameworks, ugh. (Well, to be a truly clean OS X app, the frameworks should each have their own translation resources, for just what's in the framework, but that's a big task.)

Generally, I'm just worried that all the shared resources (resources, libs, ...) will cause other problems later. Though I'm a bit puzzled how it's finding the providers - I didn't see anything in the browser startup that initializes the provider registry (or like happens in the main QGIS app (but I know little about C++ and Qt).

Member

dakcarto commented Jul 22, 2012

William,

On Sun, Jul 22, 2012 at 1:15 PM, William Kyngesburye
reply@reply.github.com
wrote:

sorry, I'm not very good at testing, and only ran the program and quit.

I missed the providers angle, but then it should be a link to "qgis" inside the plugins folder, unless there is more in the Qt plugin subfolders that the browser could use.

Well, it seems to work with only Plugins/qgis symlinked. However,
since the browser also shows the contents of text-based sources and
attribute table field contents, I'm guessing that the Plugins/codecs
folder will need to be symlinked as well.

Spatialite dbs seem to work (fully via provider?), so not sure if
Plugins/sqldrivers is needed, though I suspect it would be if some db
views use joins, or the interface for the browser starts using Qt for
some SQLite stuff directly (I can see this if it starts saving
user-defined groupings of content, not just favorites of the directory
tree). That only leaves Plugins/imageformats, which I don't think are
used by the browser (only embedded Qt support for the png toolbar
icons).

Nonetheless, since the browser is merely using the QGIS API, and is
pulling in much of it, I don't see a problem with all Plugins being
symlinked. (I'm running both QGIS and Browser at same time with no ill
effects, which is how it's supposed to work, i.e. via drag/drop to
QGIS.app.) The bundling is really just a Mac nicety (in this case),
since on Linux the browser binary just directly uses the same
underlying resources.

Resources really should be specific to an application. Maybe the browser string translations need to be split into their own file. Though there is probably a lot shared from the frameworks, ugh. (Well, to be a truly clean OS X app, the frameworks should each have their own translation resources, for just what's in the framework, but that's a big task.)

I don't think translations need split. Since the browser app is using
the API, direct access to the translations shouldn't be an issue. Note
that QGIS app settings and widgets are being directly accessed via the
API (WMS, etc. settings are known and editable via their native QGIS
widgets).

Also, I'm running this under QgsDebug output. When testing the browser
without a full symlink to QGIS.app's Resources folder, I get this:

src/core/qgscoordinatereferencesystem.cpp: 304: (loadFromDb) failed :
/Users/larrys/QGIS/github.com/QGIS_app/QGIS.app/Contents/MacOS/bin/QGIS
Browser.app/Contents/MacOS/../Resources/resources/srs.db does not
exist!

So it looks like the browser is a fairly complete QGIS API app, in the
sense that many aspects of the underlying QGIS API are being leveraged
(srs.db in this instance). Since the Browser is only going to get more
feature-complete in the future [0], access to the full QGIS.app's
Resources folder will be necessary. I wouldn't be surprised if someone
added Python support to the Browser (would be a great feature).

[0] http://hub.qgis.org/wiki/quantum-gis/Google_Summer_of_Code_2012#Improvements-to-Browser

Generally, I'm just worried that all the shared resources (resources, libs, ...) will cause other problems later. Though I'm a bit puzzled how it's finding the providers - I didn't see anything in the browser startup that initializes the provider registry (or like happens in the main QGIS app (but I know little about C++ and Qt).

In src/browser/qgsbrowser.cpp it includes "qgsproviderregistry.h"
which pretty much pulls in all the provider stuff.

Since the Browser is just leveraging the API, I don't think there is a
problem with sharing resources at this time (bundle-to-bundle). If it
starts having features that are outside of QGIS's or Qt's APIs, then
it could be an issue, and the apps should probably be separated.

As an initial test, I just moved the qbrowser binary into the same
directory as the QGIS binary and launched it via Terminal (originally
how I got it to work). So, basically, other than faux-bundling for
Mac, I think it should be considered to have the same resource
requirements as QGIS itself, especially as it gets more
feature-complete.

Without faux-bundling within in the current QGIS.app structure, it
would require a lot of extra packaging work and size (like you
mentioned). I don't think that's necessary at this stage. In many
respects it is just another version of QGIS, though launched as a
separate process. I would think users should be 'OK' with having only
alias access to the Browser (better than none).

The only potential problem with this setup would be if parts of the
base bundle are dynamically updated by the QGIS.app, but I don't think
that currently happens. Looks like everything in that bundle structure
is static after install.

Larry


Reply to this email directly or view it on GitHub:
qgis#197 (comment)

Member

dakcarto commented Jul 22, 2012

Seems to be working fine now with #68bf5ec commit. Tested drag-drop with as many providers as I could.

Will test on 10.6.8 at work tomorrow. Thanks.

yjacolin pushed a commit to yjacolin/QGIS that referenced this pull request Oct 4, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment