Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#9 MultiCellLayout crashes

v1.0 (example)
closed-fixed
5
2002-10-08
2002-10-04
Michael Traxler
No

Hi Germain,

the bugs are getting more and more unimportant, that's
why I chose this system to report.
When using MultiCellLayout in a little bit more
complicated layout than just buttons, it will crash
with a SIGSEGV.

Example code attached.
PerlQt3 newest from cvs.

Michael

Discussion

  • germain garand
    germain garand
    2002-10-05

    • assigned_to: nobody --> germaingarand
    • status: open --> open-accepted
     
  • germain garand
    germain garand
    2002-10-05

    Logged In: YES
    user_id=145773

    Ah yes, thank you much...
    This is yet another "clever reference counting" failure.

    As $Layout1 has no parent ( its "undef"), PerlQt think it
    must destroy it when its my variable holder goes out of scope.

    So the fix is turning $Layout1 into an attribute that won't
    go out of scope.
    I need to fix puic for this "undef" parent case.

     
  • Logged In: YES
    user_id=623079

    Hi!
    It is better now, but it still crashed when using "deeper"
    layouts...
    See attached file....

    Michael

     
  • still multi_cell_layout crashes..

     
    Attachments
  • Logged In: YES
    user_id=623079

    Hi!
    It is better now, but it still crashed when using "deeper"
    layouts...
    See attached file....

    Michael

     
  • still multi_cell_layout crashes..

     
    Attachments
  • Logged In: YES
    user_id=623079

    Maybe a better and shorter example of crashing code:
    package Form3;
    use Qt;
    use Qt::isa qw(Qt::Dialog);
    use Qt::attributes qw(
    );

    sub NEW
    {
    shift->SUPER::NEW(@_[0..3]);

    if( name() eq "unnamed" )
    {
    setName("Form3");
    }
    resize(574,323);
    setCaption(trUtf8("Form3"));

    my $LayoutWidget = Qt::Widget(this, '$LayoutWidget');
    $LayoutWidget->setGeometry(Qt::Rect(110, 50, 299, 221));
    my $Layout19 = Qt::GridLayout($LayoutWidget, 1, 1, 0, 6,
    '$Layout19');

    my $Layout17 = Qt::VBoxLayout(undef, 0, 6, '$Layout17');

    my $Layout9 = Qt::VBoxLayout(undef, 0, 6, '$Layout9');
    $Layout17->addLayout($Layout9);

    my $Layout16 = Qt::HBoxLayout(undef, 0, 6, '$Layout16');
    $Layout17->addLayout($Layout16);

    $Layout19->addMultiCellLayout($Layout17, 1, 2, 0, 0);
    }

    1;

     
  • germain garand
    germain garand
    2002-10-07

    Logged In: YES
    user_id=145773

    Hi Michael,
    your other examples exhibit basically the same problem
    (layout widget with 'undef' parent stored inside a "my"
    variable).

    Widgets/Layouts without parents (top-level widgets or
    top-level layouts) are necessarily destroyed when their
    associated perl variable is destroyed because otherwise
    there would be no criterium for destroying them : they would
    all hang around in memory until the program finishes.
    Instead, the rule is : if the object still has a parent,
    keep it until this parent is destroyed.
    Then the parent destruction triggers the destruction of all
    childs.

    So the only correct solution is to fix puic to have all
    layouts without parent stored inside an attribute.
    I think I've fixed it in my local puic but I've got a
    problem : I can't reproduce a form wich led to the output
    you have...

    Could you send me an .ui file producing such an output ?
    (or even better, explain me how you damn manage to build
    them in the designer ! :o)

    Thanks,
    Germain

     
  •  
    Attachments
  • Logged In: YES
    user_id=623079

    Hi!
    I attached an .ui file (form3.ui) which generates false code...
    What you have to do is:
    Just write an application and don't think of it.... It will
    happen...
    That's how I came to the bug :-).
    It's not so easy to reproduce it on purpose...

    Michael

     
  • germain garand
    germain garand
    2002-10-08

    Logged In: YES
    user_id=145773

    Hi Michael,

    I was wrong with my "undef" assumption : in fact, every
    Layout that is added to a parent layout gets reparented as a
    child of this parent layout (pretty logical, eh)... so there
    is absolutely no problem with 'undef' layouts. All should be
    garbage collected correctly.

    Now there is a bug in Qt 3.0.x for
    QGridLayout::addMultiCellLayout() : it fails to reparent its
    QLayout argument (looks fixed in Qt-3.1 beta)...

    So I've added a hack in PerlQt to preserve the pointer if
    that function is called (checkout Qt.pm)

    Sorry for the long delay, I've got few time to work on
    PerlQt those days ;-/

    Cheers,
    Germain

     
  • germain garand
    germain garand
    2002-10-08

    • status: open-accepted --> closed-fixed