Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt5 support #3

Open
wants to merge 11 commits into
base: smtk-head
Choose a base branch
from
Open

Conversation

mathstuf
Copy link

This is on top of smtk-head. Qt4 is no longer supported here. One failing test; uninspected.

CC: @robertmaynard

@mathstuf
Copy link
Author

Looks like testenum is not deterministic? @mwoehlke, is this a problem with the QAtomicPointer changes?

@mwoehlke-kitware
Copy link

Um... I have no idea. Did I write that test? 😁

@mathstuf
Copy link
Author

Git says no, but is anyone else still around Shiboken who would know more?

@mwoehlke-kitware
Copy link

Well, you might also ask on pyside-dev@googlegroups.com...

@vibraphone
Copy link

If this gets merged to smtk-head, then we need to tag before merging so that people with Qt4 can continue to build SMTK. Or this should accommodate both Qt4 and Qt5.

@mathstuf
Copy link
Author

@vibraphone Agreed.

Email sent to pyside-dev@.

@mathstuf
Copy link
Author

And email bounced from pyside-dev@. Looks like we're on our own here :/ .

@mwoehlke-kitware
Copy link

You have to join the group.

@mathstuf
Copy link
Author

So upstream is non-responsive. @mwoehlke-kitware, mind looking over the changes to see if there's anything I missed when porting?

#include <QTime>
#include <QQueue>
#include <QDir>
#include <QtCore/QDebug>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pedantic: using tll(Qt5::Core), I don't believe this is necessary... if supporting both Qt4/Qt5 is a goal, it might be better to omit these changes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...that said, the only modules Shiboken should care about are ones that have not been refactored (i.e. Shiboken is not using headers that exist in different modules between Qt4 and Qt5), and this style of include in theory works with Qt4 also. (More to the point, I noticed there is at least one such include prior to these changes...)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dual Qt4/Qt5 support isn't a necessity. It can be done if it isn't too much work, but seeing as upstream doesn't care much about this, I expect we may be left with a fork here anyways :( .

QAtomicPointer no longer has the method and its usage is never atomic
anyways, so just reimplement the method.
@mwoehlke-kitware
Copy link

Totally unrelated to QAtomicPointer. The underlying problem is that enums are not being processed in well-defined order (they're being processed in the order they appear in a QHash, and QHash in Qt 5 has explicitly non-deterministic ordering, even for same inputs), where they need to be processed in the order they are declared.

See https://codereview.qt-project.org/106505 and https://codereview.qt-project.org/106506 for patches.

@mathstuf
Copy link
Author

OK, that fixes the non-deterministic failures; now to track down the actual failures.

@mathstuf
Copy link
Author

Seems to be related to failures around primitive-type elements not being converted properly? Doesn't work with your patches; works without.

Modify _ScopeModelItem to return enums (from the enums() method) in the
order that they were added (which presumably is the order in which they
were declared). We must do this because we must process enumerations in
the same order in order to resolve values, as later declared enums may
refer to values from earlier declared enums (and in fact, this is
exactly the case in the 'testenum' test), and the order we get just from
QHash may not match declaration order.

Change-Id: I15a05df98a2cee7ecccb6c82d3f9017735281245
In the same vein as the previous commit, process global enums in order
added (which presumably is declaration order). For what we're doing at
this point, this may not be as critical, but again is needed to avoid a
spurious test failure.

Change-Id: If32a07fee2e7e9b7699e01eda3408ed57855e947
@mwoehlke-kitware
Copy link

Did you do a clean build? The only test failure I'm seeing is sample_templateinheritingclass. (After a clean build. I was getting some odd behavior prior, but didn't dig as the clean build made it go away.)

@mathstuf
Copy link
Author

On Tue, Feb 17, 2015 at 11:49:43 -0800, Matthew Woehlke wrote:

Did you do a clean build? The only test failure I'm seeing is
sample_templateinheritingclass. (After a clean build. I was getting
some odd behavior prior, but didn't dig as the clean build made it go
away.)

Same here now with a clean build. Shiboken needs to get its deps fixed I
guess.

@mwoehlke-kitware
Copy link

Oh, joy... it's a heisenbug; in the process of throwing around qDebug()s to try to isolate where it's going sideways, I've made it go away entirely...

It looks like it's failing to add functions (methods) from a base class, although the inheritence is set up correctly AFAICT.

@mwoehlke-kitware
Copy link

Ah... it's worse than that; it looks like shiboken's output is no longer deterministic (probably for similar reasons). Just doing repeated builds, sometimes the test passes, sometimes it doesn't. (Also, I can verify that the generated code differs between runs.)

@mwoehlke-kitware
Copy link

The non-determinism also seems to be the cause of most of the tests crashing for some builds. Things are being initialized in non-deterministic order, with the result that some times base classes get initialized first, and some times they don't, depending on a random seed when writing the generated code.

@mwoehlke-kitware
Copy link

So.... dcee65c is part of the problem; it pokes holes in the topology. Why was this change needed? The commit message isn't very helpful.

@mathstuf
Copy link
Author

I don't remember exactly :( . Is there some reason why that spot shouldn't check for template characters? If it is reverted, is all well again? My guess is that it has to do with finding shared_ptr<A> -> shared_ptr<B> hierarchies.

@mwoehlke-kitware
Copy link

I don't remember exactly :( . Is there some reason why that spot shouldn't check for template characters?

Er... no. Did you mean "template base classes"? getBaseClasses() always differentiates between templates and non-templates, but dcee65c causes it to not return any template base classes. (When computing the topology. Which means that the topology is broken.)

My guess is that it has to do with finding shared_ptr<A> -> shared_ptr<B> hierarchies.

Funny you should mention that... 😀 That's also broken (looks like that's what went wrong when you get a build with lots of crashing). I suspect there is no topology for those happening at all. (Which isn't too surprising, since it's a feature that we added.)

I'm inclined to think that dcee65c should be reverted...

This reverts commit dcee65c. I can't
figure out why the original change is needed, and Ben doesn't remember
either, and it pokes holes in the topology generation, by breaking the
graph anywhere inheritance happens through a template type, resulting in
an incorrect ordering of the output class list. (Which in turn causes
bugs because derived classes get initialized before their bases.)
@mathstuf
Copy link
Author

On Fri, Feb 20, 2015 at 11:16:47 -0800, Matthew Woehlke wrote:

Er... no. Did you mean "template base classes"? getBaseClasses()
always differentiates between templates and non-templates, but
dcee65c causes it to not return any template base classes. (When
computing the topology. Which means that the topology is broken.)

Well, checking for '<' is how it detected templates, so yes. I think the
thing is that it needed to make shared_ptr not-a template base class
for shared_ptr or some such. The commit might be necessary, but the
logic broken.

Funny you should mention that... 😀 That's also broken
(looks like that's what went wrong when you get a build with lots of
crashing). I suspect there is no topology for those happening at
all
. (Which isn't too surprising, since it's a feature that we
added.)

I'm inclined to think that dcee65c should be reverted...

If things still work, I have no attachment to it.

@mwoehlke-kitware
Copy link

I think the thing is that it needed to make shared_ptr not-a template base class for shared_ptr or some such.

That... may be an issue. In fact, the crash I'm looking at right now is because ptr<B> is being initialized with base class ptr<A>, but ptr<A> has not been initialized yet. However... dcee65c is not relevant to that. What I'm seeing is actually rather strange; when the topology is built, ptr<B> has no base classes... but when its initialization is written, it has base class ptr<A>. I'm... not sure why the list of base classes is changing.

More accurately, ShibokenGenerator::getBaseClasses is returning a larger set of classes than AbstractMetaBuilder::getBaseClasses, for the same metaclass instance. That being the case, I'd be willing to believe that the former needs such a chance, but dcee65c made changes to the latter, which don't help.

@mwoehlke-kitware
Copy link

...and on that note, you specifically added that behavior in b2e7c19.

@mwoehlke-kitware
Copy link

See https://codereview.qt-project.org/106919 ...although it only addresses part of the problem.

When building the class topology, don't skip classes, even if we are not
going to generate code for them. This is necessary to get the topology
order correct in a case such as C derived from B derived from A, where B
is not generated, but initializing C depends on A being initialized
first. Without this change, there is no guaranteed ordering between A
and C in such a case.

(In particular, this comes up in the Photon test; Photon::ValueIdentity
derives from Photon::TemplateBase, which derives from Photon::Base.
However, this was not being reflected in the topology, and as a result,
it was just luck that the initialization order was correct anyway.)
Remove concept of "injected dependencies"; this overloads the "injected"
term to mean something totally different, and no longer has any use
since the previous commit. Add a concept of "extra" dependencies, used
to form topology edges without actually modifying the class hierarchy,
which is used to ensure that pointer wrappers follow the classes that
they wrap. (This may not be strictly necessary, but it seems advisable.)
Add comments explaining better what traverseInstantiation is doing with
respect to the class hierarchy. Only treat a pointer-to-B as a subclass
of a pointer-to-A when there is only one template argument.
Always check for an exact match first, before checking for a template
match. This fixes failure to find the base class when the base is an
instantiation.
@mathstuf
Copy link
Author

mathstuf commented Apr 6, 2015

These commits by @mwoehlke-kitware seem to fix things and works for SMTK locally.

@rodfersou
Copy link

I think we can merge what @mwoehlke-kitware did and open a new issue / pull request explaining the "other part of the problem"

Who agree with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants