weixin_39716043
weixin_39716043
2020-12-26 10:15

AppImage on Ubuntu

I created a Qt application which is packed into an AppImage archive for distribution. Then the use clicks on the AppImage archive the application starts up.

I'm using SingleApplication to prevent secondary application to be fired. It works fine when I run the binary directly, but once binary and libraries are packed into an AppImage archive, it stops working.

Any idea? I tried to use SingleApplication::Mode::System and SingleApplication::Mode::User but none of them works. As I said, it stops working only when packed inside an AppImage format.

Regards,

Giovanni

该提问来源于开源项目:itay-grudev/SingleApplication

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39995280 weixin_39995280 4月前

    It works fine for me inside an AppImage. I use the user mode. You need to give some more details of how you use SingleApplication in your code, and how you build your AppImage. Here is how I build AppImages for Strawberry: https://github.com/jonaski/strawberry-buildbot/blob/master/config/master/strawberry/builders.py#L385

    They are uploaded here: https://builds.strawberrymusicplayer.org/appimage/

    It works both when starting from the terminal and in thunar. I use XFCE.

    点赞 评论 复制链接分享
  • weixin_39716043 weixin_39716043 4月前

    Thanks for the answer, I will try to add more information.

    I'm using the latest Qt 5.13.1 on Xubuntu 19.04. To create the AppImage I used the command tool linuxdeployqt which is available here: https://github.com/probonopd/linuxdeployqt

    I'm using the following command.

    
    /opt/linuxdeployqt/linuxdeployqt-continuous-x86_64.AppImage AppDir/usr/share/applications/MyApp.desktop \
    -appimage \
    -extra-plugins=iconengines,imageformats \
    -no-translations \
    -no-copy-copyright-files
    

    I followed what is in the example "sending_arguments" and set the 3rd parameter to true because I want all secondary applications to send a message to the primary application and then quit.

    What I wanted to do is to allow the user to click on a file associated to the application and open it up. If the user then clicks on a different file with the same extension, the file will be loaded into the primary application.

    As I said, just before packing the application into the AppImage format, it works fine. I can prevent a secondary application to startup and send a message to the primary application. That is why I thought it was an AppImage issue.

    Additionally, I tried this snippet of code called RunGuard which is available here: https://stackoverflow.com/questions/5006547/qt-best-practice-for-a-single-instance-app-protection

    This small piece of code uses a QSharedMemory and QSystemSemaphore to prevent secondary applications to startup but there is no client-server communication. This piece of code works fine even if the application is packed into an AppImage archive and that is the reason why I reported the issue here.

    Regards

    Giovanni

    点赞 评论 复制链接分享
  • weixin_39879674 weixin_39879674 4月前

    Were there anything in the logs? I've places warnings and errors in several places to aid debugging.

    点赞 评论 复制链接分享
  • weixin_39716043 weixin_39716043 4月前

    I'm not entirely sure what the problem was, it could have also been some local configuration that I'm not able to grasp. In the end I decided to take a different approach. I added the code in attachment in case you find it useful.

    code.zip

    One important requirement I had was to test and guarantee the behavior of a single application in Windows, Linux and MacOS, so I decided to create a component instead of extending the QApplication.

    Additionally, I'm not interested in having multiple secondary applications running so I dropped all that part.

    Regards,

    Giovanni

    点赞 评论 复制链接分享
  • weixin_39879674 weixin_39879674 4月前

    Very well.

    点赞 评论 复制链接分享

相关推荐