Issue Details (XML | Word | Printable)

Key: IZPACK-20
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Julien Ponge
Reporter: Brett Bergquist
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
IzPack

The launcher will never prompt you to install a JRE if there is no JRE on the system

Created: 01/Mar/08 07:59 AM   Updated: 26/Mar/08 02:56 AM   Resolved: 16/Mar/08 10:04 AM
Return to search
Component/s: Native launcher
Affects Version/s: None
Fix Version/s: 4.0.0

Time Tracking:
Not Specified

File Attachments: 1. Text File IZPACK-20.patch (4 kB)

Environment: WinXP Pro


 Description  « Hide

If you do not have a JRE installed, the launcher will never prompt you do download one or install one from a local directory even if the launcher.ini is setup correctly to do so. This is a problem with the QProcess:execute method of the Qt library. The problem is that the code that looks like:

if (QProcess::execute("java", QStringList("-version")) == 0)
{
    javaExecPath = "java";
    return true;
}

always succeeds even if there is no "java.exe" anywhere on the system. The cause of this is the implementation of QProcess::execute. It's implementation looks like:

int QProcess::execute(const QString &program, const QStringList &arguments)
{
    QProcess process;

    process.setReadChannelMode(QProcess::ForwardedChannels);
    process.start(program, arguments);
    process.waitForFinished(-1);

   return  process.exitCode();
}

The problem is that internally, the "start" method uses "CreateProcess" to create the process. Of course this will fail if the program does not exist. But the code never sets the "exitCode" member in this case; it still has the value 0. The cleanup code in "start' sets the "error" member in this case. But since the QProcess is created locally, this member cannot be queried.

I've fixed this problem locally by adding a 2 new methods to "launcher.cpp" that look like:

int Launcher::execute(const QString &program, const QStringList &arguments)
{
    QProcess process;

    process.setReadChannelMode(QProcess::ForwardedChannels);
    process.start(program, arguments);
    process.waitForFinished(-1);

    int exitCode = process.exitCode();
    if (process.error() == QProcess::FailedToStart)
    {
        exitCode = -1;
    }

    return exitCode;
}

int Launcher::execute(const QString &program, const QStringList &arguments)
{
    QProcess process;

    process.setReadChannelMode(QProcess::ForwardedChannels);
    process.start(program,);
    process.waitForFinished(-1);

    int exitCode = process.exitCode();
    if (process.error() == QProcess::FailedToStart)
    {
        exitCode = -1;
    }

    return exitCode;
}

and changed all references of QProcess::execute to "Launcher::execute". This works fine now. I can supply a patch.

But I would like to know how launcher.exe is built and linked. What compiler chain (MinGW? win32-g++?) Also, how was this linked as when I rebuild, this uses the Qt library with DLL's and now the exe relies on them as well as the mingw DLL.



Julien Ponge made changes - 01/Mar/08 09:13 AM
Field Original Value New Value
Fix Version/s 4.0.0 [ 14071 ]
Julien Ponge added a comment - 01/Mar/08 11:31 AM

Great report!

I do not have a Qt / MingW environment under hand, but here is how I built the last version:

  1. get Qt with MingW embedded
  2. compile a static version of Qt (it is dynamic by default)
  3. compile the launcher
  4. strip it using either the 'strip' tool from the MinGW toolchain, or run UPX

I haven't checked with the latest version of Qt, but removing the MinGW DLL dependency was tricky. I wrote about it: http://home.izforge.com/index.php/2007/02/20/334-qt-static-linking-and-removing-the-mingw-dll-dependency, I hope it will help you!

Thanks for your work!


Julien Ponge added a comment - 01/Mar/08 11:34 AM - edited

I am assigning this to myself as I will handle the patches when Brett has them ready.


Julien Ponge made changes - 01/Mar/08 11:34 AM
Assignee Julien Ponge [ jponge ]
Brett Bergquist added a comment - 11/Mar/08 09:46 PM

This fixes the described problem and also one other. If the supplied JRE installation failed, no warning was given. The test was giving a warning if the JRE installer returned a "0" exit code but "0" means success and not an error. There was an extraneous "!" in the test.


Brett Bergquist made changes - 11/Mar/08 09:46 PM
Attachment IZPACK-20.patch [ 33128 ]
Julien Ponge added a comment - 16/Mar/08 10:04 AM

The patch provided by Brett has been applied.


Julien Ponge made changes - 16/Mar/08 10:04 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Julien Ponge added a comment - 19/Mar/08 04:02 AM

The issue will be closed when the Windows binary has been updated in SVN (getting the right build environment is not a trivial task).


Julien Ponge added a comment - 26/Mar/08 02:56 AM

The Win32 executable has been updated in the SVN trunk.


Julien Ponge made changes - 26/Mar/08 02:56 AM
Status Resolved [ 5 ] Closed [ 6 ]