Re: [PyQt] Strange bug in PyQt

2008-08-09 Thread Roberto Alsina
On Saturday 09 August 2008 19:09:46 Andreas Pakulat wrote:
> So alltogether attached is a c++ app that reproduces the problem, feel
> free to use that when sending a bugreport to TT. (the main.cpp and .ui
> file can just be placed into an empty dir and then qmake
> -project;qmake;make can be run to build the app)

Reported.

-- 
 ("\''/").__..-''"`-. . Roberto Alsina
 `9_ 9  )   `-. ().`-._.`)  KDE Developer (MFCH)
 (_Y_.)' ._   ) `._`.  " -.-'  http://lateral.netmanagers.com.ar 
  _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia   
(l)-'' ((i).' ((!.'   according to alexa.com (27/5/2007) 

Debugging is twice as hard as writing the code in the first place. 
Therefore, if you write the code as cleverly as possible, you are, 
by definition, not smart enough to debug it. --Brian W. Kernighan
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Strange bug in PyQt

2008-08-09 Thread Andreas Pakulat
On 09.08.08 18:12:12, Roberto Alsina wrote:
> On Saturday 09 August 2008 15:57:01 Andreas Pakulat wrote:
> > On 09.08.08 14:09:17, Roberto Alsina wrote:
> > > On Saturday 09 August 2008 09:40:31 Andreas Pakulat wrote:
> > > > On 08.08.08 19:42:19, Roberto Alsina wrote:
> > > > > On Friday 08 August 2008 18:43:12 Andreas Pakulat wrote:
> > > > > > On 08.08.08 16:36:35, Roberto Alsina wrote:
> > > > > > > I don't know how to explain it, si I have to use pictures.
> > > > > >
> > > > > > Are you talking about the cut-off menu items? Or what? Which parts
> > > > > > of the pictures should we look into/
> > > > >
> > > > > Cutoff menu items, varying font sizes, the "Search" label, even the
> > > > > left qtreeview's header is weird.
> > > > >
> > > > > Loos like font metrics were all cray.
> > > >
> > > > Hmm, can you produce a small example that demonstrates the problem? Its
> > > > quite weird that loading an icon in a different way has such an effect.
> > > > I'm suspecting a bit that this might be an issue on your machine, so it
> > > > would be good to test it on other machines/different setups.
> > >
> > > Attached is an example, and it got even weirder.
> > >
> > > 1) It doesn't depend on actually using the QIcon, only on creating it
> > > before there's a QApplication.
> >
> > Thats a bug in your application, Qt doesn't support doing much - if
> > anything at all - with it until a QApp is created.
> 
> Sure, but it's a bug that should give an error instead of messing the UI :-)
> 
> > > 2) On windows you can't do that. (gives an error "Must construct a
> > > QApplication before a QPaintDevice" which looks reasonable to me) [Qt
> > > 4.4.1]
> > >
> > > 3) On Arch Linux I get cutoff menus and small fonts on the QTreeView
> > > [4.4.1]
> >
> > Indeed. I can confirm the problem, however it only appears with the
> > complete example. Just using a static QIcon before creating a QApp
> > doesn't produce it (i.e. just creating a mainwindow and adding a few
> > menus is not triggering the problem). So I can just guess its got
> > something to do with the icon + .ui file.
> 
> I tested it with several different SVG icons and the behaviour is the same.
> 
> The UI file is created with designer, just a menu with three items and a 
> treewidget, no properties set on anything.
> 
> > I also noticed that Qt and PyQt bail out if you use actual files in the
> > filesystem, as opposed to resources.
> 
> That's interesting.
> 
> I am leaning now towards believing it's a unix-specific Qt bug and not a PyQt 
> bug. I should do a C++ project to test it (ugh)

Here are some more observations:

- loading the .svg from the disk also breaks the ui, so you can leave
  out the .qrc stuff - one component less that could be the cause
- as I said before one needs to use a .ui file and apparently it needs
  to have a QAbstractItemView in the mainwindow, without it its also not
  showing the problem.

So alltogether attached is a c++ app that reproduces the problem, feel
free to use that when sending a bugreport to TT. (the main.cpp and .ui
file can just be placed into an empty dir and then qmake
-project;qmake;make can be run to build the app)

Andreas

-- 
A day for firm decisions!  Or is it?
#include 
#include 
#include 
#include 

#include "ui_myui.h"

static QIcon ic("/home/andreas/temp/bug_demo_cpp/folder.svg");

int main(int argc, char** argv)
{
QApplication app(argc,argv);
QMainWindow* mainWindow = new QMainWindow();
Ui::MainWindow bug;
bug.setupUi(mainWindow);
QDirModel* model = new QDirModel();
bug.treeView->setModel(model);
mainWindow->show();
app.exec();
}

 MainWindow
 
  
   
0
0
800
600
   
  
  
   MainWindow
  
  
   

 0
 27
 800
 549

   
   

 

   
  
  
   

 0
 0
 800
 27

   
   

 Doo


   
   

 Bar

   
   
   
  
  
   

 0
 576
 800
 24

   
  
  
   
nfd
   
  
 
 
 

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Strange bug in PyQt

2008-08-09 Thread Roberto Alsina
On Saturday 09 August 2008 15:57:01 Andreas Pakulat wrote:
> On 09.08.08 14:09:17, Roberto Alsina wrote:
> > On Saturday 09 August 2008 09:40:31 Andreas Pakulat wrote:
> > > On 08.08.08 19:42:19, Roberto Alsina wrote:
> > > > On Friday 08 August 2008 18:43:12 Andreas Pakulat wrote:
> > > > > On 08.08.08 16:36:35, Roberto Alsina wrote:
> > > > > > I don't know how to explain it, si I have to use pictures.
> > > > >
> > > > > Are you talking about the cut-off menu items? Or what? Which parts
> > > > > of the pictures should we look into/
> > > >
> > > > Cutoff menu items, varying font sizes, the "Search" label, even the
> > > > left qtreeview's header is weird.
> > > >
> > > > Loos like font metrics were all cray.
> > >
> > > Hmm, can you produce a small example that demonstrates the problem? Its
> > > quite weird that loading an icon in a different way has such an effect.
> > > I'm suspecting a bit that this might be an issue on your machine, so it
> > > would be good to test it on other machines/different setups.
> >
> > Attached is an example, and it got even weirder.
> >
> > 1) It doesn't depend on actually using the QIcon, only on creating it
> > before there's a QApplication.
>
> Thats a bug in your application, Qt doesn't support doing much - if
> anything at all - with it until a QApp is created.

Sure, but it's a bug that should give an error instead of messing the UI :-)

> > 2) On windows you can't do that. (gives an error "Must construct a
> > QApplication before a QPaintDevice" which looks reasonable to me) [Qt
> > 4.4.1]
> >
> > 3) On Arch Linux I get cutoff menus and small fonts on the QTreeView
> > [4.4.1]
>
> Indeed. I can confirm the problem, however it only appears with the
> complete example. Just using a static QIcon before creating a QApp
> doesn't produce it (i.e. just creating a mainwindow and adding a few
> menus is not triggering the problem). So I can just guess its got
> something to do with the icon + .ui file.

I tested it with several different SVG icons and the behaviour is the same.

The UI file is created with designer, just a menu with three items and a 
treewidget, no properties set on anything.

> I also noticed that Qt and PyQt bail out if you use actual files in the
> filesystem, as opposed to resources.

That's interesting.

I am leaning now towards believing it's a unix-specific Qt bug and not a PyQt 
bug. I should do a C++ project to test it (ugh)

-- 
 ("\''/").__..-''"`-. . Roberto Alsina
 `9_ 9  )   `-. ().`-._.`)  KDE Developer (MFCH)
 (_Y_.)' ._   ) `._`.  " -.-'  http://lateral.netmanagers.com.ar 
  _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia   
(l)-'' ((i).' ((!.'   according to alexa.com (27/5/2007) 

Debugging is twice as hard as writing the code in the first place. 
Therefore, if you write the code as cleverly as possible, you are, 
by definition, not smart enough to debug it. --Brian W. Kernighan

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Strange bug in PyQt

2008-08-09 Thread Andreas Pakulat
On 09.08.08 14:09:17, Roberto Alsina wrote:
> On Saturday 09 August 2008 09:40:31 Andreas Pakulat wrote:
> > On 08.08.08 19:42:19, Roberto Alsina wrote:
> > > On Friday 08 August 2008 18:43:12 Andreas Pakulat wrote:
> > > > On 08.08.08 16:36:35, Roberto Alsina wrote:
> > > > > I don't know how to explain it, si I have to use pictures.
> > > >
> > > > Are you talking about the cut-off menu items? Or what? Which parts of
> > > > the pictures should we look into/
> > >
> > > Cutoff menu items, varying font sizes, the "Search" label, even the left
> > > qtreeview's header is weird.
> > >
> > > Loos like font metrics were all cray.
> >
> > Hmm, can you produce a small example that demonstrates the problem? Its
> > quite weird that loading an icon in a different way has such an effect.
> > I'm suspecting a bit that this might be an issue on your machine, so it
> > would be good to test it on other machines/different setups.
> 
> Attached is an example, and it got even weirder.
> 
> 1) It doesn't depend on actually using the QIcon, only on creating it before 
> there's a QApplication.

Thats a bug in your application, Qt doesn't support doing much - if
anything at all - with it until a QApp is created.

> 2) On windows you can't do that. (gives an error "Must construct a 
> QApplication before a QPaintDevice" which looks reasonable to me) [Qt 4.4.1]
>
> 3) On Arch Linux I get cutoff menus and small fonts on the QTreeView [4.4.1]

Indeed. I can confirm the problem, however it only appears with the
complete example. Just using a static QIcon before creating a QApp
doesn't produce it (i.e. just creating a mainwindow and adding a few
menus is not triggering the problem). So I can just guess its got
something to do with the icon + .ui file.

I also noticed that Qt and PyQt bail out if you use actual files in the
filesystem, as opposed to resources.

Andreas

-- 
Stay away from hurricanes for a while.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Strange bug in PyQt

2008-08-09 Thread Roberto Alsina
On Saturday 09 August 2008 09:40:31 Andreas Pakulat wrote:
> On 08.08.08 19:42:19, Roberto Alsina wrote:
> > On Friday 08 August 2008 18:43:12 Andreas Pakulat wrote:
> > > On 08.08.08 16:36:35, Roberto Alsina wrote:
> > > > I don't know how to explain it, si I have to use pictures.
> > >
> > > Are you talking about the cut-off menu items? Or what? Which parts of
> > > the pictures should we look into/
> >
> > Cutoff menu items, varying font sizes, the "Search" label, even the left
> > qtreeview's header is weird.
> >
> > Loos like font metrics were all cray.
>
> Hmm, can you produce a small example that demonstrates the problem? Its
> quite weird that loading an icon in a different way has such an effect.
> I'm suspecting a bit that this might be an issue on your machine, so it
> would be good to test it on other machines/different setups.

Attached is an example, and it got even weirder.

1) It doesn't depend on actually using the QIcon, only on creating it before 
there's a QApplication.

2) On windows you can't do that. (gives an error "Must construct a 
QApplication before a QPaintDevice" which looks reasonable to me) [Qt 4.4.1]

3) On Arch Linux I get cutoff menus and small fonts on the QTreeView [4.4.1]

4) On KUbuntu I get smaller fonts on the QTreeView but no cutoff menus [4.4.0]

-- 
 ("\''/").__..-''"`-. . Roberto Alsina
 `9_ 9  )   `-. ().`-._.`)  KDE Developer (MFCH)
 (_Y_.)' ._   ) `._`.  " -.-'  http://lateral.netmanagers.com.ar 
  _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia   
(l)-'' ((i).' ((!.'   according to alexa.com (27/5/2007) 

Debugging is twice as hard as writing the code in the first place. 
Therefore, if you write the code as cleverly as possible, you are, 
by definition, not smart enough to debug it. --Brian W. Kernighan


bug_demo.tgz
Description: application/compressed-tar
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Strange bug in PyQt

2008-08-09 Thread Andreas Pakulat
On 08.08.08 19:42:19, Roberto Alsina wrote:
> On Friday 08 August 2008 18:43:12 Andreas Pakulat wrote:
> > On 08.08.08 16:36:35, Roberto Alsina wrote:
> > > I don't know how to explain it, si I have to use pictures.
> >
> > Are you talking about the cut-off menu items? Or what? Which parts of
> > the pictures should we look into/
> 
> Cutoff menu items, varying font sizes, the "Search" label, even the left 
> qtreeview's header is weird.
> 
> Loos like font metrics were all cray.

Hmm, can you produce a small example that demonstrates the problem? Its
quite weird that loading an icon in a different way has such an effect.
I'm suspecting a bit that this might be an issue on your machine, so it
would be good to test it on other machines/different setups.

Andreas

-- 
Your aim is high and to the right.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Strange bug in PyQt

2008-08-08 Thread Roberto Alsina
On Friday 08 August 2008 18:43:12 Andreas Pakulat wrote:
> On 08.08.08 16:36:35, Roberto Alsina wrote:
> > I don't know how to explain it, si I have to use pictures.
>
> Are you talking about the cut-off menu items? Or what? Which parts of
> the pictures should we look into/

Cutoff menu items, varying font sizes, the "Search" label, even the left 
qtreeview's header is weird.

Loos like font metrics were all cray.

> > In the good version, I create the "star" icon for each item:
> >
> >   item1.setIcon(QtGui.QIcon(':/star.svg'))
> >
> > In the bad version, I created a global:
> >
> > star=QtGui.QIcon(':/star.svg')
> >
> > And used it instead:
> >
> >   item1.setIcon(star)
>
> Note that the icon here might vanish as soon as the function is left, so
> your items might have invalid icons - unless they do a deep-copy of the
> given item.

It's in the module's scope so it shouldn't be deleted while the module is 
imported. Also since the icon is diplayed I'm assuming it's not deleted.

-- 
 ("\''/").__..-''"`-. . Roberto Alsina
 `9_ 9  )   `-. ().`-._.`)  KDE Developer (MFCH)
 (_Y_.)' ._   ) `._`.  " -.-'  http://lateral.netmanagers.com.ar 
  _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia   
(l)-'' ((i).' ((!.'   according to alexa.com (27/5/2007) 

Debugging is twice as hard as writing the code in the first place. 
Therefore, if you write the code as cleverly as possible, you are, 
by definition, not smart enough to debug it. --Brian W. Kernighan

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Strange bug in PyQt

2008-08-08 Thread Andreas Pakulat
On 08.08.08 16:36:35, Roberto Alsina wrote:
> I don't know how to explain it, si I have to use pictures.

Are you talking about the cut-off menu items? Or what? Which parts of
the pictures should we look into/

> In the good version, I create the "star" icon for each item:
> 
>   item1.setIcon(QtGui.QIcon(':/star.svg'))
> 
> In the bad version, I created a global:
> 
> star=QtGui.QIcon(':/star.svg')
> 
> And used it instead:
> 
>   item1.setIcon(star)

Note that the icon here might vanish as soon as the function is left, so
your items might have invalid icons - unless they do a deep-copy of the
given item.

Andreas

-- 
You're a card which will have to be dealt with.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Strange bug in PyQt

2008-08-08 Thread Roberto Alsina
I don't know how to explain it, si I have to use pictures.

Here's how my app looks when things go "bad":

http://flickr.com/photos/ralsina/2744179213/

Here's the "good":

http://flickr.com/photos/ralsina/2744178603/

What's the difference in the code? This:

In the good version, I create the "star" icon for each item:

  item1.setIcon(QtGui.QIcon(':/star.svg'))

In the bad version, I created a global:

star=QtGui.QIcon(':/star.svg')

And used it instead:

  item1.setIcon(star)

I had the same thing happen to another app before and never figured out why it 
happened.

I am using 

qt 4.4.0
pyqt 4.4.2
python 2.5.2

On Linux.

Any ideas?


-- 
 ("\''/").__..-''"`-. . Roberto Alsina
 `9_ 9  )   `-. ().`-._.`)  KDE Developer (MFCH)
 (_Y_.)' ._   ) `._`.  " -.-'  http://lateral.netmanagers.com.ar 
  _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia   
(l)-'' ((i).' ((!.'   according to alexa.com (27/5/2007) 

Debugging is twice as hard as writing the code in the first place. 
Therefore, if you write the code as cleverly as possible, you are, 
by definition, not smart enough to debug it. --Brian W. Kernighan

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt