Code Monkey home page Code Monkey logo

Comments (8)

niraj-modi avatar niraj-modi commented on June 14, 2024

Similarly with null Layout Data and layout.type = SWT.VERTICAL; BorderLayout.getMax() also throws NPE as below:
Exception in thread "main" java.lang.NullPointerException
at org.eclipse.swt.layout.BorderLayout.lambda$5(BorderLayout.java:244)
at java.base/java.util.stream.ReferencePipeline$4$1.accept(ReferencePipeline.java:212)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.IntPipeline.reduce(IntPipeline.java:496)
at java.base/java.util.stream.IntPipeline.max(IntPipeline.java:459)
at org.eclipse.swt.layout.BorderLayout.getMax(BorderLayout.java:244)
at org.eclipse.swt.layout.BorderLayout.getMax(BorderLayout.java:240)
at org.eclipse.swt.layout.BorderLayout.computeSize(BorderLayout.java:149)
at org.eclipse.swt.widgets.Composite.computeSizeInPixels(Composite.java:217)
at org.eclipse.swt.widgets.Control.computeSize(Control.java:663)
at org.eclipse.swt.widgets.Control.pack(Control.java:2198)
at org.eclipse.swt.widgets.Control.pack(Control.java:2168)
at org.eclipse.swt.snippets.Snippet379.main(Snippet379.java:50)

from eclipse.platform.swt.

joel-majano avatar joel-majano commented on June 14, 2024

I can take a look at this issue and begin working on a fix. Just want to confirm, @laeubi do you have a patch in progress already?

from eclipse.platform.swt.

laeubi avatar laeubi commented on June 14, 2024

@joel-majano I haven't yet prepared a patch and contributions are always welcome, so please go ahead
Just add me as a reviewer then, otherwise I'll be looking into this next week. I think the first step would be to enhance the test-case to reproduce this issue.

from eclipse.platform.swt.

joel-majano avatar joel-majano commented on June 14, 2024

I was able to recreate the NPE that Niraj commented on, but to recreate the original issue I have to set SWT.HORIZONTAL and call shell.pack() explicitly (in both cases). Are these the expected failure conditions?

from eclipse.platform.swt.

laeubi avatar laeubi commented on June 14, 2024

At least the stacktrace indicates that there is a pack() involved:

at org.eclipse.swt.widgets.Control.pack(Control.java:2198)

from eclipse.platform.swt.

joel-majano avatar joel-majano commented on June 14, 2024

Okay, in that case, I get this issue even if LayoutData is not null. Just taking Snippet 379, adding a shell.pack() call right before shell.open() creates the NPE. SWT.VERTICAL creates an NPE in BorderLayout.getMax() and SWT.HORIZONTAL creates an NPE in BorderLayout.getTotal().

Also, what would be the expected behaviour of pack()? I know BorderLayout has some spacing/margin dimensions specified, so is pack() a valid call with BorderLayout?

from eclipse.platform.swt.

laeubi avatar laeubi commented on June 14, 2024

I don't see a reason why pack() should not be supported.

from eclipse.platform.swt.

joel-majano avatar joel-majano commented on June 14, 2024

Alright, still looking into this, no patch yet.

from eclipse.platform.swt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.