Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the autostart for AppImages. See #2504. #2739

Merged
merged 1 commit into from
Dec 21, 2020

Conversation

hrittich
Copy link
Contributor

@hrittich hrittich commented Dec 18, 2020

For details please see the discussion in #2504. This fix sets the application path to the enviornment variable APPIMAGE, if the variable exists and points to an existing file. According to the discussion, this should fix #2504.

I cannot, however, check whether this fixes the bug, since I cannot build the AppImage, because the build-appimage.sh is aparently expecting to be run on a certain version of a certain Linux distribution under some CI/CD system. (And I do not know which one.)

Would be great, if someone could build the AppImage and test it.

@hrittich
Copy link
Contributor Author

hrittich commented Dec 18, 2020

Okay. I have tested the AppImage. It works unless the file name contains a space. I am going to fix this in a few minutes.

@hrittich hrittich force-pushed the master branch 2 times, most recently from c085267 to f896fae Compare December 18, 2020 13:35
@hrittich
Copy link
Contributor Author

So, I have tested the AppImage. The patch fixes the bug for me.

@@ -18,6 +18,7 @@
*/

#include <QStandardPaths>
#include <QtGlobal>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You sure this is needed? I'd expect QtGlobal to be pulled (indirectly) by QStandardPaths already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header is needed according to the Qt documentation. It might not be needed, but not including it means relying on undocumented behavior and might break in future updates.

// When running inside an AppImage, we need to set the path to the
// AppImage instead of the path to the executable
QString executablePath;
QString appImagePath = qEnvironmentVariable("APPIMAGE");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be const, so I'd go for: const auto appImagePath = qEnvironmentVariable("APPIMAGE");

// AppImage instead of the path to the executable
QString executablePath;
QString appImagePath = qEnvironmentVariable("APPIMAGE");
if (!appImagePath.isNull() && QFile::exists(appImagePath)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional but since I'm a const freak I'd advise going for the ternary operator so that executablePath can be made const, it looked something like that I think:

const auto runningInsideAppImage = !appImagePath.isNull() && QFile::exists(appImagePath);
const auto executablePath = runningInsideAppImage ? appImagePath : executablePath;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually a nice idea, b.c. it gets rid of the uninitialized variable, which I do not like.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's also why I tend to auto more as well, it prevents uninitialized variables. ;-)

@er-vin
Copy link
Member

er-vin commented Dec 21, 2020

/rebase

@er-vin
Copy link
Member

er-vin commented Dec 21, 2020

Could you please rebase on latest master? Otherwise this looks good to go IMHO.

@nextcloud-desktop-bot
Copy link

AppImage file: Nextcloud-PR-2739-5fc778bfaa33b65f352e7df229bc5b69d18eb1bc-x86_64.AppImage

To test this change/fix you can simply download above AppImage file and test it.

Please make sure to quit your existing Nextcloud app and backup your data.

@hrittich
Copy link
Contributor Author

I have tested the AppImage once more. Looks fine.

@er-vin er-vin merged commit 1c46101 into nextcloud:master Dec 21, 2020
@er-vin
Copy link
Member

er-vin commented Dec 21, 2020

/backport to stable-3.1

@er-vin
Copy link
Member

er-vin commented Dec 21, 2020

Thanks a lot for the contribution!

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

Successfully merging this pull request may close these issues.

Appimage 3.0.2 not starting with user login or with restart and login
3 participants