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

Program cannot be started #63

Closed
ITSweets opened this issue Jul 23, 2022 · 10 comments
Closed

Program cannot be started #63

ITSweets opened this issue Jul 23, 2022 · 10 comments

Comments

@ITSweets
Copy link

ITSweets commented Jul 23, 2022

Describe the bug
Qml program fails to start

To Reproduce
Hi, I'm using QtJambi to run a Qml program under Linux, the program doesn't start properly, and the console has some information printed

QCoreApplication.shutdown() called before closing all windows.Deleting window ["Hello World"] (QQuickWindowQmlImpl).

Before 5.15.3 did not have this problem on the Windows platform, is it because of the Linux platform or because of the version of QtJambi? How to solve this problem?

The complete code is as follows:

1. Launcher.java

import io.qt.core.QUrl;
import io.qt.gui.QGuiApplication;
import io.qt.qml.QQmlApplicationEngine;
public class Launcher
{
public static void main(String[] args)
{
QGuiApplication.initialize(args);
var engine = new QQmlApplicationEngine();
engine.load(new QUrl("qrc:main.qml"));
QGuiApplication.exec();
QGuiApplication.shutdown();
}
}

2. main.qml

import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQml 2.15
Window
{
id: app
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Button
{
objectName: "Button01"
text: "Continue"
}
}

Looking forward to your reply.

System (please complete the following information):

  • OS: [LinuxMint 20.3
  • Java version OpenJDK 11
  • QtJambi version 5.15.7
  • Qt 5.15.2
@omix
Copy link
Contributor

omix commented Jul 25, 2022

Thank you for your bug report. I found the issue and it's actually an error in QGuiApplication.exec(). Unfortunately, the error is also in QCoreApplication.exec(). A workaround is to use QApplication.exec() which requires QtWidget library. However, it is not necessary to use QApplication.initialize().

@ITSweets
Copy link
Author

So are you ready to fix it in the next QtJambi? I know you've been busy adapting to the Android platform recently. I don't know if you have any ideas to fix. It seems that this error does not exist on Windows, because I used it on Windows before and it worked fine. No thanks, I love this framework and don't want QtJambi to die, I want it to be the strongest GUI for Java.

@omix
Copy link
Contributor

omix commented Jul 25, 2022

Yes, I already fixed it on my system locally and will include the fix in the next release. Propably, I will publish it as maven artifact 5.15.7a without further notice.

@omix
Copy link
Contributor

omix commented Jul 25, 2022

QCoreApplication.shutdown() called before closing all windows.Deleting window ["Hello World"] (QQuickWindowQmlImpl).

That's only a warning. The top-level window has not been deleted because the qml engine still exists.
You can make engine = null; before QGuiApplication.shutdown(); to remove the warning.

@ITSweets
Copy link
Author

ITSweets commented Jul 25, 2022

I have downloaded qtjambi-5.15.7a.jar and other dependencies are all 5.15.7. but
QGuiApplication.exec(); still doesn't work, the program starts flashing and then exits. But changing QGuiApplication.exec(); to QApplication.exec(); works fine. This didn't fix it either. . . .

Before the modification [cannot run] I hope that this kind of thing can run normally.

QGuiApplication.initialize(args);
var engine = new QQmlApplicationEngine();
engine.load(new QUrl("qrc:main.qml"));
QGuiApplication.exec();
engine = null;
QGuiApplication.shutdown();

After modification [normal operation]

QGuiApplication.initialize(args);
var engine = new QQmlApplicationEngine();
engine.load(new QUrl("qrc:main.qml"));
QApplication.exec();
engine = null;
QGuiApplication.shutdown();

Why am I stuck with QGuiApplication.exec(); ? Because Qml is this api in the main program of pure Qt. Otherwise you will have a look. . .

@omix
Copy link
Contributor

omix commented Jul 25, 2022

Sorry for confusing you. What I ment was to publish the bugfix as qtjambi-native-platformXY-5.15.7a.jar. The java component qtjambi-5.15.7a.jar only contains a bugfix needed in Android. You will not see any difference in other platforms.

So, up to now, I did not publish the changes and it takes a while to do so. I'll let you know.

@omix
Copy link
Contributor

omix commented Jul 25, 2022

I uploaded a bugfix patch version.
See: https://search.maven.org/artifact/io.qtjambi/qtjambi-native-linux-x64
new version is 5.15.7a
It should be available shortly.

@ITSweets
Copy link
Author

OK, I got it. So have your revised source code been submitted to the GitHub repository? Because today I want to compile QtJambi by myself based on Qt 5.15.5 to solve the compatibility problem.

omix added a commit that referenced this issue Jul 26, 2022
@omix omix closed this as completed Jul 26, 2022
@ITSweets
Copy link
Author

I just tested with Qt 5.15.7 on the Windows platform and found that QGuiApplication.exec(); causes the program to exit instantly after startup. This problem does not only exist on Linux, but also exists on Windows. Maybe you already know that QtJambi on Windows platform has this problem, but I still want to remind you. But having said that, in fact, there was no problem in the previous 5.15.3 version. It may only appear when you upgrade later.

@omix
Copy link
Contributor

omix commented Jul 27, 2022

Yes, I know. I uploaded bugfix binaries for all platforms.

omix added a commit that referenced this issue Aug 19, 2022
Bugfix Issue #60
Bugfix Issue #62
Bugfix Issue #63
Bugfix Issue #64
Bugfix Issue #66
Bugfix Issue #69
omix added a commit that referenced this issue Jul 25, 2023
omix added a commit that referenced this issue Jul 25, 2023
Bugfix Issue #60
Bugfix Issue #62
Bugfix Issue #63
Bugfix Issue #64
Bugfix Issue #66
Bugfix Issue #69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants