Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, April 2007
Auto-updating my Qt application


Message 1 in thread

Hi,

This isn't exactly a completely Qt question. I have developed a messenger 
for local lan. And I keep making it better. I wish that my messenger keeps 
updating itself automatically so that there is no need to notify people to 
download the latest version.

I can understand that to update, I can download the latest version from 
one of the lan servers and put it in the application directory, but there 
are a few issues.

1. In Windows, I can't replace/overwrite the executable for my app if its 
already running.
2. In any case, Windows or Linux, I don't know how to 'restart' my 
application with the new version which gets downloaded.

Please give me suggestions. I have come up with a dirty solution.

I have two applications, ichatupdate and ichat. ichatupdate connects to 
local lan server and downloads any updates for ichat. Then ichat gets 
executed, so that we have the latest version everytime we 'start' the 
application. This sequence of executions can be put in a bat file or shell 
file.

What if I want to give a functionality to update while the application is 
running? Is there a way out... anything Qt has to offer?

I am using Qt 4.2.2 with Mingw on Windows and G++ on Linux.

Regards,
-- 
 [ signature omitted ] 

Message 2 in thread

Hi,

Using Qt's plugin system you may reload your code.
Plugins are loaded at runtime. They can be unloaded.
If you distribute a new version. You download the plugin.
Unload your current loaded plugin-library and load the new one.
Should work. I've never testet that but sound logical
if I didnt missed a oint or another.

Regards,
Stefan

On Monday 16 April 2007 13:45, Anurag Singh Rana wrote:
> Hi,
>
> This isn't exactly a completely Qt question. I have developed a messenger
> for local lan. And I keep making it better. I wish that my messenger keeps
> updating itself automatically so that there is no need to notify people to
> download the latest version.
>
> I can understand that to update, I can download the latest version from
> one of the lan servers and put it in the application directory, but there
> are a few issues.
>
> 1. In Windows, I can't replace/overwrite the executable for my app if its
> already running.
> 2. In any case, Windows or Linux, I don't know how to 'restart' my
> application with the new version which gets downloaded.
>
> Please give me suggestions. I have come up with a dirty solution.
>
> I have two applications, ichatupdate and ichat. ichatupdate connects to
> local lan server and downloads any updates for ichat. Then ichat gets
> executed, so that we have the latest version everytime we 'start' the
> application. This sequence of executions can be put in a bat file or shell
> file.
>
> What if I want to give a functionality to update while the application is
> running? Is there a way out... anything Qt has to offer?
>
> I am using Qt 4.2.2 with Mingw on Windows and G++ on Linux.
>
> Regards,

--
 [ signature omitted ] 

Message 3 in thread

Anurag Singh Rana schrieb:
> Hi,
> ...
> 1. In Windows, I can't replace/overwrite the executable for my app if
> its already running.

If you really need to update the whole application/libraries (as opposed
to "unloadable" plugins metioned in another reply) you really need to
shut it down, that's correct (also on Unix - unlike on Windows you *can*
indeed overwrite *.so/executable files even while they are running, but
of course the running application won't notice so that's of no much use;
the app only notices the changes when it is restarted).

For example Firefox (browser) does this, but I can only assume how they
do it: Firefox checks for updates and if it finds any Firefox probably
starts an external "Updater" application (QProcess). This Updater then
closes Firefox (for example pass the PID along as command line
parameter), downloads the updates, installs them and restarts Firefox
(your application).

Off course if you need to update the updater itself... that's a "chicken
and egg" problem :) So you better get it right(tm) the first time :)

Cheers, Oliver

--
 [ signature omitted ] 

Message 4 in thread

 
> Off course if you need to update the updater itself... that's 
> a "chicken and egg" problem :) So you better get it right(tm) 
> the first time :)

But with an easy fix!  Just make your main application the updater of
your update application, so every time you launch your actual
application it checks to see if the updater needs to be updated, if so
you update the updater first.  Then once the updater is updated, your
application checks to see if the application itself is up-to-date, if
not it runs the updater!

Sean

--
 [ signature omitted ] 

Message 5 in thread

> For example Firefox (browser) does this, but I can only assume how they
> do it: Firefox checks for updates and if it finds any Firefox probably
> starts an external "Updater" application (QProcess). This Updater then
> closes Firefox (for example pass the PID along as command line
> parameter), downloads the updates, installs them and restarts Firefox
> (your application).

So can we exit the main application after invoking a new process using 
QProcess? If thats possible I can try out what you suggest. I thought the 
processes invoked using QProcess will be 'children' to the main process 
and hence, closing the main one will destroy the children too.

> Off course if you need to update the updater itself... that's a "chicken
> and egg" problem :) So you better get it right(tm) the first time :)

This problem is solved... as with the previous reply... the application 
and updater can act as updaters for each other!

Can someone throw more light on the actual usage of QProcess in this 
regard?

Regards,
-- 
 [ signature omitted ]