Discussion:
[Patch] use Qt resources
(too old to reply)
Andre Poenitz
2007-10-16 21:11:23 UTC
Permalink
Could somebody on Windows please try this one?

[It should work]

Also anu observations on startup speed are welcome.

Andre'
Andre Poenitz
2007-10-16 22:22:41 UTC
Permalink
Post by Andre Poenitz
Could somebody on Windows please try this one?
[It should work]
Also anu observations on startup speed are welcome.
Slightly more complete patch attached.

Andre'
Bo Peng
2007-10-18 02:55:53 UTC
Permalink
Post by Andre Poenitz
Post by Andre Poenitz
Could somebody on Windows please try this one?
[It should work]
Also anu observations on startup speed are welcome.
Slightly more complete patch attached.
I get

src/frontends/qt4/GuiToolbar.cpp:51: undefined reference to `qInitResources()'
collect2: ld returned 1 exit status

Bo
Andre Poenitz
2007-10-18 06:18:42 UTC
Permalink
Post by Bo Peng
Post by Andre Poenitz
Post by Andre Poenitz
Could somebody on Windows please try this one?
[It should work]
Also anu observations on startup speed are welcome.
Slightly more complete patch attached.
I get
src/frontends/qt4/GuiToolbar.cpp:51: undefined reference to `qInitResources()'
collect2: ld returned 1 exit status
Scons?

There's a Resources.cpp to be build and compiled in frontends/qt4.

Andre'
Bo Peng
2007-10-18 13:47:18 UTC
Permalink
Post by Andre Poenitz
Scons?
There's a Resources.cpp to be build and compiled in frontends/qt4.
There is no such file. Did you add it to svn?

Bo
Andre Poenitz
2007-10-18 16:54:49 UTC
Permalink
Post by Bo Peng
Post by Andre Poenitz
Scons?
There's a Resources.cpp to be build and compiled in frontends/qt4.
There is no such file. Did you add it to svn?
This is a generated file built by

Resources.qrc:
echo "<!DOCTYPE RCC><RCC version='1.0'><qresource>" > $@
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file alias="\1">&</file>:' \
echo "</qresource></RCC>" >> $@

Resources.cpp: Resources.qrc
$(RCC4) $< -o $@

in the automake version.

As resources do not change very often we could add Resources.cpp to svn
but I'd rather always generate it.

Andre'
Bo Peng
2007-10-18 17:20:23 UTC
Permalink
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file alias="\1">&</file>:' \
What is the advantage of doing all these?

Bo
Bo Peng
2007-10-18 18:32:44 UTC
Permalink
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file alias="\1">&</file>:' \
OK. Scons is fixed for this. Abdel seems to have the same problem with cmake.

Bo
Andre Poenitz
2007-10-18 18:47:40 UTC
Permalink
Post by Bo Peng
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file alias="\1">&</file>:' \
OK. Scons is fixed for this. Abdel seems to have the same problem with cmake.
I did ask people to test he patch, didn't I?

Andre'
Bo Peng
2007-10-18 18:53:39 UTC
Permalink
Post by Andre Poenitz
Post by Bo Peng
OK. Scons is fixed for this. Abdel seems to have the same problem with cmake.
I did ask people to test he patch, didn't I?
You did ask, but I had no idea what your patch was about, and did not test.

Bo
Andre Poenitz
2007-10-18 18:46:26 UTC
Permalink
Post by Bo Peng
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file alias="\1">&</file>:' \
What is the advantage of doing all these?
Compiled-in resources vs 600 seperately installed files?

Andre'
Bo Peng
2007-10-18 18:51:35 UTC
Permalink
Post by Andre Poenitz
Post by Bo Peng
What is the advantage of doing all these?
Compiled-in resources vs 600 seperately installed files?
Makes sense. Thanks.

BTW, you use find to get all the images under lib/images, but some of
them are unused. Scons only compiles the used ones that are listed in
scons_manifest.

Bo
Andre Poenitz
2007-10-18 20:59:36 UTC
Permalink
Post by Bo Peng
Post by Andre Poenitz
Post by Bo Peng
What is the advantage of doing all these?
Compiled-in resources vs 600 seperately installed files?
Makes sense. Thanks.
BTW, you use find to get all the images under lib/images, but some of
them are unused. Scons only compiles the used ones that are listed in
scons_manifest.
Would anybody object to remove the unused ones?

Andre'
Bo Peng
2007-10-18 21:07:56 UTC
Permalink
Post by Andre Poenitz
Post by Bo Peng
BTW, you use find to get all the images under lib/images, but some of
them are unused. Scons only compiles the used ones that are listed in
scons_manifest.
Would anybody object to remove the unused ones?
I am not quite sure. For example, I can add font-bold to
ui/stdtoolbar.inc, and font-bold.png would better be there...

Bo
Martin Vermeer
2007-10-19 01:07:26 UTC
Permalink
Post by Bo Peng
Post by Andre Poenitz
Post by Bo Peng
BTW, you use find to get all the images under lib/images, but some of
them are unused. Scons only compiles the used ones that are listed in
scons_manifest.
Would anybody object to remove the unused ones?
I am not quite sure. For example, I can add font-bold to
ui/stdtoolbar.inc, and font-bold.png would better be there...
Bo
+1 (Surely you mean font-strong.png :-)

- Martin
Alfredo Braunstein
2007-10-19 07:43:00 UTC
Permalink
Post by Andre Poenitz
Post by Bo Peng
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file
| alias="\1">&</file>:' \
What is the advantage of doing all these?
Compiled-in resources vs 600 seperately installed files?
And this is an advantage because?

Note that it's a genuine question, I simply don't know.

A/
Abdelrazak Younes
2007-10-19 08:06:35 UTC
Permalink
Post by Alfredo Braunstein
Post by Andre Poenitz
Post by Bo Peng
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file
| alias="\1">&</file>:' \
What is the advantage of doing all these?
Compiled-in resources vs 600 seperately installed files?
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded on
startup now that we have the math panels in the toolbars.

Abdel.
Helge Hafting
2007-10-19 08:26:57 UTC
Permalink
Post by Abdelrazak Younes
Post by Alfredo Braunstein
Post by Andre Poenitz
Post by Bo Peng
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file
| alias="\1">&</file>:' \
What is the advantage of doing all these?
Compiled-in resources vs 600 seperately installed files?
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded
on startup now that we have the math panels in the toolbars.
Good - faster startup is always a good thing, the delay is noticeable now.

Helge Hafting
Andre Poenitz
2007-10-19 17:08:58 UTC
Permalink
Post by Helge Hafting
Post by Abdelrazak Younes
Post by Alfredo Braunstein
Post by Andre Poenitz
Post by Bo Peng
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file
| alias="\1">&</file>:' \
What is the advantage of doing all these?
Compiled-in resources vs 600 seperately installed files?
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded
on startup now that we have the math panels in the toolbars.
Good - faster startup is always a good thing, the delay is noticeable now.
It removes ~0.4s out of a total ~7s here, so ~5%. Not too much actually,
but not bad either.

It's hard to get 'real numbers' as after the first start there's a lot
chached by the system (total time then <2s here).

Andre'
Helge Hafting
2007-10-22 09:08:45 UTC
Permalink
Post by Andre Poenitz
Post by Helge Hafting
Post by Abdelrazak Younes
Post by Alfredo Braunstein
Post by Andre Poenitz
Post by Bo Peng
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file
| alias="\1">&</file>:' \
What is the advantage of doing all these?
Compiled-in resources vs 600 seperately installed files?
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded
on startup now that we have the math panels in the toolbars.
Good - faster startup is always a good thing, the delay is noticeable now.
It removes ~0.4s out of a total ~7s here, so ~5%. Not too much actually,
but not bad either.
Everything helps :-)
Post by Andre Poenitz
It's hard to get 'real numbers' as after the first start there's a lot
chached by the system (total time then <2s here).
2s to start LyX from cache, 3s to start LyX with some
document. More when there's no cache of course.

Helge Hafting

Jean-Marc Lasgouttes
2007-10-19 08:45:30 UTC
Permalink
Post by Abdelrazak Younes
Post by Alfredo Braunstein
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded
on startup now that we have the math panels in the toolbars.
Is it still possible for a user to provide his own icons for the
toolbar? Otherwise the patch is a big regression for me (especially
with 'presumed' faster loading).

JMarc
Abdelrazak Younes
2007-10-19 08:56:28 UTC
Permalink
Post by Jean-Marc Lasgouttes
Post by Abdelrazak Younes
Post by Alfredo Braunstein
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded
on startup now that we have the math panels in the toolbars.
Is it still possible for a user to provide his own icons for the
toolbar?
As far as I see no, not yet.
Post by Jean-Marc Lasgouttes
Otherwise the patch is a big regression for me (especially
with 'presumed' faster loading).
This should be fixed yes. We probably need an API for icon loading; but
wait, we already have that in GuiToolbar.cpp:

static QIcon getIcon(FuncRequest const & f, bool unknown)

So, what do we want to support? I guess adding one or two cases for user
icons should be easy.

Abdel.
Jean-Marc Lasgouttes
2007-10-19 09:02:01 UTC
Permalink
Post by Abdelrazak Younes
This should be fixed yes. We probably need an API for icon loading;
static QIcon getIcon(FuncRequest const & f, bool unknown)
So, what do we want to support? I guess adding one or two cases for
user icons should be easy.
Yes it should.

JMarc
Andre Poenitz
2007-10-19 17:10:32 UTC
Permalink
Post by Jean-Marc Lasgouttes
Post by Abdelrazak Younes
Post by Alfredo Braunstein
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded
on startup now that we have the math panels in the toolbars.
Is it still possible for a user to provide his own icons for the
toolbar? Otherwise the patch is a big regression for me (especially
with 'presumed' faster loading).
*grr*

Have you ever done that?

Andre'
Alfredo Braunstein
2007-10-19 08:37:46 UTC
Permalink
Post by Abdelrazak Younes
Post by Alfredo Braunstein
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded on
startup now that we have the math panels in the toolbars.
Just trying to upset Andre'. Icons are really read on startup or just the
first time the panel is created (if it is an auto panel)? Because in the
second case the change could actually mean *slower* startup times...

A/
Abdelrazak Younes
2007-10-19 09:04:18 UTC
Permalink
Post by Alfredo Braunstein
Post by Abdelrazak Younes
Post by Alfredo Braunstein
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded on
startup now that we have the math panels in the toolbars.
Just trying to upset Andre'. Icons are really read on startup or just the
first time the panel is created (if it is an auto panel)?
Good question.
Post by Alfredo Braunstein
Because in the
second case the change could actually mean *slower* startup times...
I don't think the difference would be noticeable... the lib/images/math
directory is only 6 megs in size. I don't know how the resource file is
used within Qt but I guess that not everything is put in memory... not
sure though.

Abdel.
Alfredo Braunstein
2007-10-19 09:07:19 UTC
Permalink
Post by Abdelrazak Younes
Good question.
Post by Alfredo Braunstein
Because in the
second case the change could actually mean *slower* startup times...
I don't think the difference would be noticeable... the lib/images/math
Didn't this start as a presumable startup time improvement?
Post by Abdelrazak Younes
directory is only 6 megs in size. I don't know how the resource file is
Note that lib/images (*including* lib/images/math) is just 7.9M.
Post by Abdelrazak Younes
used within Qt but I guess that not everything is put in memory... not
sure though.
Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm
images was only 2.9M. Did the xpm -> png change had some impact on load
time?

A/
Abdelrazak Younes
2007-10-19 09:24:47 UTC
Permalink
Post by Alfredo Braunstein
Post by Abdelrazak Younes
Good question.
Post by Alfredo Braunstein
Because in the
second case the change could actually mean *slower* startup times...
I don't think the difference would be noticeable... the lib/images/math
Didn't this start as a presumable startup time improvement?
I guess that was Andre' rationale yes. I am just giving some insight
that's all :-)
Post by Alfredo Braunstein
Post by Abdelrazak Younes
directory is only 6 megs in size. I don't know how the resource file is
Note that lib/images (*including* lib/images/math) is just 7.9M.
Right, we make a good team!
Post by Alfredo Braunstein
Post by Abdelrazak Younes
used within Qt but I guess that not everything is put in memory... not
sure though.
Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm
images was only 2.9M. Did the xpm -> png change had some impact on load
time?
dunno...

Abdel.
Abdelrazak Younes
2007-10-19 09:33:45 UTC
Permalink
Post by Abdelrazak Younes
Post by Alfredo Braunstein
Post by Abdelrazak Younes
directory is only 6 megs in size. I don't know how the resource file is
Note that lib/images (*including* lib/images/math) is just 7.9M.
Right, we make a good team!
Hum not so good as we are both wrong!
We should not count the .svn/ directory... images/math/ is actually 2.9M.
Post by Abdelrazak Younes
Post by Alfredo Braunstein
Post by Abdelrazak Younes
used within Qt but I guess that not everything is put in memory... not
sure though.
Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm
images was only 2.9M. Did the xpm -> png change had some impact on load
time?
No the size are approximately the same, see above...

Abdel.
Alfredo Braunstein
2007-10-19 09:41:19 UTC
Permalink
Post by Abdelrazak Younes
Hum not so good as we are both wrong!
We should not count the .svn/ directory... images/math/ is actually 2.9M.
Haha you're right.
Post by Abdelrazak Younes
Post by Alfredo Braunstein
Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm
images was only 2.9M. Did the xpm -> png change had some impact on load
time?
No the size are approximately the same, see above...
Oh, that's a relief actually ;-)

A/
Andre Poenitz
2007-10-19 17:27:54 UTC
Permalink
Post by Alfredo Braunstein
Post by Abdelrazak Younes
Good question.
Post by Alfredo Braunstein
Because in the
second case the change could actually mean *slower* startup times...
I don't think the difference would be noticeable... the lib/images/math
Didn't this start as a presumable startup time improvement?
No. It started as code decontamination. I did not even mention speed.
Post by Alfredo Braunstein
Post by Abdelrazak Younes
directory is only 6 megs in size. I don't know how the resource file is
Note that lib/images (*including* lib/images/math) is just 7.9M.
Could depend on the filesystem and thje tools used to compute 'size'.
Post by Alfredo Braunstein
Post by Abdelrazak Younes
used within Qt but I guess that not everything is put in memory... not
sure though.
Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm
images was only 2.9M. Did the xpm -> png change had some impact on load
time?
I wonder why you try to invent problems.

In rev 19000 we have 1169691 for wc -c {*,*/*}.* in lib/images,
in current trunk it is 235212. That's a bit more than a fifth
of the original size.

Andre'
Andre Poenitz
2007-10-19 17:18:11 UTC
Permalink
Post by Abdelrazak Younes
Post by Alfredo Braunstein
Post by Abdelrazak Younes
Post by Alfredo Braunstein
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded on
startup now that we have the math panels in the toolbars.
Just trying to upset Andre'. Icons are really read on startup or just the
first time the panel is created (if it is an auto panel)?
Good question.
Post by Alfredo Braunstein
Because in the
second case the change could actually mean *slower* startup times...
I don't think the difference would be noticeable... the lib/images/math
directory is only 6 megs in size. I don't know how the resource file is
used within Qt but I guess that not everything is put in memory... not
sure though.
One can have external resources, but the patch uses internal resources,
and it results in a increase of the binary of 261 k.

Andre'
Andre Poenitz
2007-10-19 17:10:01 UTC
Permalink
Post by Alfredo Braunstein
Post by Abdelrazak Younes
Post by Alfredo Braunstein
And this is an advantage because?
Presumably faster loading. I haven't tested yet but I can imagine that
reading one big file on disk is faster than reading 600 small files
(this is for sure on Windows). Note that most of the icons are loaded on
startup now that we have the math panels in the toolbars.
Just trying to upset Andre'. Icons are really read on startup or just the
first time the panel is created (if it is an auto panel)? Because in the
second case the change could actually mean *slower* startup times...
They were read at once. I checked that with strace (that's btw why
I stumbled over that funny new cache...)

Andre'
Andre Poenitz
2007-10-19 17:05:56 UTC
Permalink
Post by Alfredo Braunstein
Post by Andre Poenitz
Post by Bo Peng
Post by Andre Poenitz
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file
| alias="\1">&</file>:' \
What is the advantage of doing all these?
Compiled-in resources vs 600 seperately installed files?
And this is an advantage because?
Faster load times (one mmap vs 600 stat + 600 read), faster installation
(especially on Windows lots of small files are poison to performance)
and last but not least nicer user-side code.

Compare

FileName const file = support::libFileSearch("images", "closetab", "xpm");
closeTabButton->setIcon(QPixmap(toqstr(file.absFilename()));

to

closeTabButton->setIcon(":/images/closetab.png");

Andre'
Jean-Marc Lasgouttes
2007-10-19 08:50:23 UTC
Permalink
Post by Andre Poenitz
Post by Bo Peng
Post by Andre Poenitz
Scons?
There's a Resources.cpp to be build and compiled in frontends/qt4.
There is no such file. Did you add it to svn?
This is a generated file built by
find $(top_srcdir)/lib/images -name '*.png' \
| sed -e 's:$(top_srcdir)/lib/\(.*\):<file alias="\1">&</file>:' \
It would be better to use the list of icons that we have anyway in
Makefile.am.

JMarc
Peter Kümmel
2007-10-18 19:41:43 UTC
Permalink
Post by Andre Poenitz
Post by Andre Poenitz
Could somebody on Windows please try this one?
[It should work]
Also anu observations on startup speed are welcome.
Slightly more complete patch attached.
Andre'
+
+static void initializeResources()
+{
+ extern void qInitResources();
+ static bool initialized = false;
+ if (!initialized) {
+ qInitResources();
+ initialized = true;
+ }
+}
+
+

I've replaced your qInitResources() with the 'official' Qt
Q_INIT_RESOURCE(Resources) because on windows the
rcc generates qInitResources_Resources().

Also cmake is now up to date.

Peter
Bo Peng
2007-10-18 22:21:42 UTC
Permalink
Post by Peter Kümmel
I've replaced your qInitResources() with the 'official' Qt
Q_INIT_RESOURCE(Resources) because on windows the
rcc generates qInitResources_Resources().
I do not know what is going on here, but Linux/qt does not have
qInitResources_Resources()... and now I am getting

src/frontends/qt4/GuiToolbar.cpp:50: undefined reference to
`qInitResources_Resources()'

Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc
-name option?)

Bo
Bo Peng
2007-10-19 15:06:21 UTC
Permalink
Post by Bo Peng
Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc
-name option?)
Please apply even a temporary fix. I can not compile under linux with this.

Bo
Enrico Forestieri
2007-10-19 15:12:08 UTC
Permalink
Post by Bo Peng
Post by Bo Peng
Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc
-name option?)
Please apply even a temporary fix. I can not compile under linux with this.
I am going to fix it. The problem is that cmake adds the -name
parameter to the rcc call.
--
Enrico
Abdelrazak Younes
2007-10-19 15:12:10 UTC
Permalink
Post by Bo Peng
Post by Bo Peng
Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc
-name option?)
Please apply even a temporary fix. I can not compile under linux with this.
Just go ahead and apply your suggested fix with #ifdef.

Abdel.
Continue reading on narkive:
Loading...