[Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Tomasz Olszak
Hello,

QImage:: transformed(const QTransform &matrix, Qt::TransformationMode mode
= Qt::FastTransformation) docs:

"Returns a copy of the image that is transformed using the given
transformation matrix and transformation mode."

But if matrix.type() == QTransform::TxNone then shallow instead of deep
copy is returned.

I'm happy to submit a fix but I don't know what is expected behaviour?
Should implementation follow docs or docs or docs follow implementation
here?

T.
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Simon Hausmann
Hi,


Could you elaborate on what you see as the discrepancy between docs and 
implementation? The docs don't say whether

it's a shallow or a deep copy, so it looks to me that the implementation is 
within the bounds of the docs.


Plus it seems sensible to return a shallow copy, doesn't it?



Simon


From: Development  on 
behalf of Tomasz Olszak 
Sent: Monday, July 11, 2016 11:38:06 AM
To: development@qt-project.org
Subject: [Development] QImage::transformed returns shallow copy for 
QTransform::TxNone matrix type.

Hello,

QImage:: transformed(const QTransform &matrix, Qt::TransformationMode mode = 
Qt::FastTransformation) docs:

"Returns a copy of the image that is transformed using the given transformation 
matrix and transformation mode."

But if matrix.type() == QTransform::TxNone then shallow instead of deep copy is 
returned.

I'm happy to submit a fix but I don't know what is expected behaviour? Should 
implementation follow docs or docs or docs follow implementation here?

T.


___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Tomasz Olszak
QImage::copy returns deep copy and has similar documentation so I assumed
that when docs say copy it means deep copy.

Let's consider common case:

1. QImage img created from raw data pointer got from e.g. driver.
2. img used in thread to perform some transforms
3. Save result as deep copy

Ensuring step 3 is most efficient and does not perform unnecessary copying
I need to write something like:

QTransform t;
if (m.type() == QTransform::TxNone)
return img.copy();
else
return img.transformed(m);

AFAIU img.transformed(m).copy() will copy twice when  m.type() !=
QTransform::TxNone right?

Don't you think that is seems strange and is not documented enough?

2016-07-11 10:59 GMT+01:00 Simon Hausmann :

> Hi,
>
>
> Could you elaborate on what you see as the discrepancy between docs and
> implementation? The docs don't say whether
>
> it's a shallow or a deep copy, so it looks to me that the implementation
> is within the bounds of the docs.
>
>
> Plus it seems sensible to return a shallow copy, doesn't it?
>
>
>
> Simon
> --
> *From:* Development  qt...@qt-project.org> on behalf of Tomasz Olszak 
> *Sent:* Monday, July 11, 2016 11:38:06 AM
> *To:* development@qt-project.org
> *Subject:* [Development] QImage::transformed returns shallow copy for
> QTransform::TxNone matrix type.
>
> Hello,
>
> QImage:: transformed(const QTransform &matrix, Qt::TransformationMode mode
> = Qt::FastTransformation) docs:
>
> "Returns a copy of the image that is transformed using the given
> transformation matrix and transformation mode."
>
> But if matrix.type() == QTransform::TxNone then shallow instead of deep
> copy is returned.
>
> I'm happy to submit a fix but I don't know what is expected behaviour?
> Should implementation follow docs or docs or docs follow implementation
> here?
>
> T.
>
>
>
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Simon Hausmann
Hi,


Thank you for the explanation of your use-case. What remains unclear to me is 
why it is necessary for you to ensure a deep copy?


Is it related to the fact that your image is created from a raw data pointer 
and after your worker thread is done, you cannot guarantee

for the life-time of the raw data anymore?


Perhaps you could use the QImage constructor that takes a cleanup function (and 
cleanupInfo pointer). If your worker thread

ends up making a copy of the image data as a result of your transformation, 
then your original copy can and will be deleted

when you discard the source of the transform() call. That is something that you 
can keep track of. Vice-versa if it's not being called,

then you know that transformed() (or generally speaking _any_ sequence of 
operations you may have done) still operate on a shallow

copy. Then you can do an explicit deep copy.


Generally speaking my impression - assuming I did understand your use-case 
correctly - is that your problem stems from the unknown

life-cycle of your data. I don't think the behavior of QImage::transformed() 
should be made worse for the common case where shallow

copying benefits performance and memory consumption.


Simon


From: Development  on 
behalf of Tomasz Olszak 
Sent: Monday, July 11, 2016 12:53:51 PM
To: development@qt-project.org
Subject: Re: [Development] QImage::transformed returns shallow copy for 
QTransform::TxNone matrix type.

QImage::copy returns deep copy and has similar documentation so I assumed that 
when docs say copy it means deep copy.

Let's consider common case:

1. QImage img created from raw data pointer got from e.g. driver.
2. img used in thread to perform some transforms
3. Save result as deep copy

Ensuring step 3 is most efficient and does not perform unnecessary copying I 
need to write something like:

QTransform t;
if (m.type() == QTransform::TxNone)
return img.copy();
else
return img.transformed(m);

AFAIU img.transformed(m).copy() will copy twice when  m.type() != 
QTransform::TxNone right?

Don't you think that is seems strange and is not documented enough?

2016-07-11 10:59 GMT+01:00 Simon Hausmann 
mailto:simon.hausm...@qt.io>>:

Hi,


Could you elaborate on what you see as the discrepancy between docs and 
implementation? The docs don't say whether

it's a shallow or a deep copy, so it looks to me that the implementation is 
within the bounds of the docs.


Plus it seems sensible to return a shallow copy, doesn't it?



Simon


From: Development 
mailto:qt...@qt-project.org>>
 on behalf of Tomasz Olszak 
mailto:olszak.tom...@gmail.com>>
Sent: Monday, July 11, 2016 11:38:06 AM
To: development@qt-project.org
Subject: [Development] QImage::transformed returns shallow copy for 
QTransform::TxNone matrix type.

Hello,

QImage:: transformed(const QTransform &matrix, Qt::TransformationMode mode = 
Qt::FastTransformation) docs:

"Returns a copy of the image that is transformed using the given transformation 
matrix and transformation mode."

But if matrix.type() == QTransform::TxNone then shallow instead of deep copy is 
returned.

I'm happy to submit a fix but I don't know what is expected behaviour? Should 
implementation follow docs or docs or docs follow implementation here?

T.



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Tomasz Olszak
The pointer comes from external object and it's lifetime is managed by it.
I need to ensure that I will not use it anymore after leaving certain
function. Hence it don't even need to be thread operation, So using clean
function won't help here.

The problem here is that you can't say if transformed returns shallow or
deep copy. Result depends on argument value. Of course the transform
returning shallow copy on identity matrix is nice but should be documented
somewhere. After reading docs I expected deep copy like from copy function.
But maybe it's only me :)

Thanks for profound explanation.


2016-07-11 12:10 GMT+01:00 Simon Hausmann :

> Hi,
>
>
> Thank you for the explanation of your use-case. What remains unclear to me
> is why it is necessary for you to ensure a deep copy?
>
>
> Is it related to the fact that your image is created from a raw data
> pointer and after your worker thread is done, you cannot guarantee
>
> for the life-time of the raw data anymore?
>
>
> Perhaps you could use the QImage constructor that takes a cleanup function
> (and cleanupInfo pointer). If your worker thread
>
> ends up making a copy of the image data as a result of your
> transformation, then your original copy can and will be deleted
>
> when you discard the source of the transform() call. That is something
> that you can keep track of. Vice-versa if it's not being called,
>
> then you know that transformed() (or generally speaking _any_ sequence of
> operations you may have done) still operate on a shallow
>
> copy. Then you can do an explicit deep copy.
>
>
> Generally speaking my impression - assuming I did understand your use-case
> correctly - is that your problem stems from the unknown
>
> life-cycle of your data. I don't think the behavior of
> QImage::transformed() should be made worse for the common case where shallow
>
> copying benefits performance and memory consumption.
>
>
> Simon
> --
> *From:* Development  qt...@qt-project.org> on behalf of Tomasz Olszak 
> *Sent:* Monday, July 11, 2016 12:53:51 PM
> *To:* development@qt-project.org
> *Subject:* Re: [Development] QImage::transformed returns shallow copy for
> QTransform::TxNone matrix type.
>
> QImage::copy returns deep copy and has similar documentation so I assumed
> that when docs say copy it means deep copy.
>
> Let's consider common case:
>
> 1. QImage img created from raw data pointer got from e.g. driver.
> 2. img used in thread to perform some transforms
> 3. Save result as deep copy
>
> Ensuring step 3 is most efficient and does not perform unnecessary copying
> I need to write something like:
>
> QTransform t;
> if (m.type() == QTransform::TxNone)
> return img.copy();
> else
> return img.transformed(m);
>
> AFAIU img.transformed(m).copy() will copy twice when  m.type() !=
> QTransform::TxNone right?
>
> Don't you think that is seems strange and is not documented enough?
>
> 2016-07-11 10:59 GMT+01:00 Simon Hausmann :
>
>> Hi,
>>
>>
>> Could you elaborate on what you see as the discrepancy between docs and
>> implementation? The docs don't say whether
>>
>> it's a shallow or a deep copy, so it looks to me that the implementation
>> is within the bounds of the docs.
>>
>>
>> Plus it seems sensible to return a shallow copy, doesn't it?
>>
>>
>>
>> Simon
>> --
>> *From:* Development > qt...@qt-project.org> on behalf of Tomasz Olszak > >
>> *Sent:* Monday, July 11, 2016 11:38:06 AM
>> *To:* development@qt-project.org
>> *Subject:* [Development] QImage::transformed returns shallow copy for
>> QTransform::TxNone matrix type.
>>
>> Hello,
>>
>> QImage:: transformed(const QTransform &matrix, Qt::TransformationMode
>> mode = Qt::FastTransformation) docs:
>>
>> "Returns a copy of the image that is transformed using the given
>> transformation matrix and transformation mode."
>>
>> But if matrix.type() == QTransform::TxNone then shallow instead of deep
>> copy is returned.
>>
>> I'm happy to submit a fix but I don't know what is expected behaviour?
>> Should implementation follow docs or docs or docs follow implementation
>> here?
>>
>> T.
>>
>>
>>
>
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Simon Hausmann
Hi,


What I'm suggesting is not to use the cleanup function to release any memory. 
As you have explained that is not possible as you do not own the data. But you 
can use

the cleanup callback as a way to determine if Qt still has a reference to your 
image data or not. If your image _was_ transformed then there should not be any 
reference

anymore. If it wasn't called, then you do need to call copy() explicitly to 
release the reference.


Another way would be to call QImage::isDetached(), but that is not public API.


Both are approached that allow you to replace your existing check with 
something that is less dependent on the implementation of QImage::transformed - 
in case

it changes one day - but are supposed to make your code more robust.



Simon


From: Tomasz Olszak 
Sent: Monday, July 11, 2016 1:40:25 PM
To: Simon Hausmann
Cc: development@qt-project.org
Subject: Re: [Development] QImage::transformed returns shallow copy for 
QTransform::TxNone matrix type.

The pointer comes from external object and it's lifetime is managed by it. I 
need to ensure that I will not use it anymore after leaving certain function. 
Hence it don't even need to be thread operation, So using clean function won't 
help here.

The problem here is that you can't say if transformed returns shallow or deep 
copy. Result depends on argument value. Of course the transform returning 
shallow copy on identity matrix is nice but should be documented somewhere. 
After reading docs I expected deep copy like from copy function. But maybe it's 
only me :)

Thanks for profound explanation.


2016-07-11 12:10 GMT+01:00 Simon Hausmann 
mailto:simon.hausm...@qt.io>>:

Hi,


Thank you for the explanation of your use-case. What remains unclear to me is 
why it is necessary for you to ensure a deep copy?


Is it related to the fact that your image is created from a raw data pointer 
and after your worker thread is done, you cannot guarantee

for the life-time of the raw data anymore?


Perhaps you could use the QImage constructor that takes a cleanup function (and 
cleanupInfo pointer). If your worker thread

ends up making a copy of the image data as a result of your transformation, 
then your original copy can and will be deleted

when you discard the source of the transform() call. That is something that you 
can keep track of. Vice-versa if it's not being called,

then you know that transformed() (or generally speaking _any_ sequence of 
operations you may have done) still operate on a shallow

copy. Then you can do an explicit deep copy.


Generally speaking my impression - assuming I did understand your use-case 
correctly - is that your problem stems from the unknown

life-cycle of your data. I don't think the behavior of QImage::transformed() 
should be made worse for the common case where shallow

copying benefits performance and memory consumption.


Simon


From: Development 
mailto:qt...@qt-project.org>>
 on behalf of Tomasz Olszak 
mailto:olszak.tom...@gmail.com>>
Sent: Monday, July 11, 2016 12:53:51 PM
To: development@qt-project.org
Subject: Re: [Development] QImage::transformed returns shallow copy for 
QTransform::TxNone matrix type.

QImage::copy returns deep copy and has similar documentation so I assumed that 
when docs say copy it means deep copy.

Let's consider common case:

1. QImage img created from raw data pointer got from e.g. driver.
2. img used in thread to perform some transforms
3. Save result as deep copy

Ensuring step 3 is most efficient and does not perform unnecessary copying I 
need to write something like:

QTransform t;
if (m.type() == QTransform::TxNone)
return img.copy();
else
return img.transformed(m);

AFAIU img.transformed(m).copy() will copy twice when  m.type() != 
QTransform::TxNone right?

Don't you think that is seems strange and is not documented enough?

2016-07-11 10:59 GMT+01:00 Simon Hausmann 
mailto:simon.hausm...@qt.io>>:

Hi,


Could you elaborate on what you see as the discrepancy between docs and 
implementation? The docs don't say whether

it's a shallow or a deep copy, so it looks to me that the implementation is 
within the bounds of the docs.


Plus it seems sensible to return a shallow copy, doesn't it?



Simon


From: Development 
mailto:qt...@qt-project.org>>
 on behalf of Tomasz Olszak 
mailto:olszak.tom...@gmail.com>>
Sent: Monday, July 11, 2016 11:38:06 AM
To: development@qt-project.org
Subject: [Development] QImage::transformed returns shallow copy for 
QTransform::TxNone matrix type.

Hello,

QImage:: transformed(const QTransform &matrix, Qt::TransformationMode mode = 
Qt::FastTransformation) docs:

"Returns a copy of the image that is transformed using the given transformation 
matrix and transformation mode."

But if matrix.type() == QTransform::TxNone then shallow instead of deep copy is 
re

Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Giuseppe D'Angelo
On Mon, Jul 11, 2016 at 1:40 PM, Tomasz Olszak  wrote:
> The problem here is that you can't say if transformed returns shallow or
> deep copy. Result depends on argument value. Of course the transform
> returning shallow copy on identity matrix is nice but should be documented
> somewhere. After reading docs I expected deep copy like from copy function.
> But maybe it's only me :)

Then always deep copy and then move on with the processing? Because
relying on shallow copies is a bit of a gamble -- by the same
reasoning, can you be sure that setPixel(x, y, color) always detaches?
What if it gets implemented in a way that first checks if the pixel
already has that color, and if so, it doesn't do anything?

-- 
Giuseppe D'Angelo
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Tomasz Olszak
Yes seems more robust but it also seems like using a sledgehammer to crack
a nut. Seems like it is not worth to burn you time for that. If everyone is
ok with docs I'm too :)

2016-07-11 12:52 GMT+01:00 Simon Hausmann :

> Hi,
>
>
> What I'm suggesting is not to use the cleanup function to release any
> memory. As you have explained that is not possible as you do not own the
> data. But you can use
>
> the cleanup callback as a way to determine if Qt still has a reference to
> your image data or not. If your image _was_ transformed then there should
> not be any reference
>
> anymore. If it wasn't called, then you do need to call copy() explicitly
> to release the reference.
>
>
> Another way would be to call QImage::isDetached(), but that is not public
> API.
>
>
> Both are approached that allow you to replace your existing check with
> something that is less dependent on the implementation of
> QImage::transformed - in case
>
> it changes one day - but are supposed to make your code more robust.
>
>
>
> Simon
> --
> *From:* Tomasz Olszak 
> *Sent:* Monday, July 11, 2016 1:40:25 PM
> *To:* Simon Hausmann
> *Cc:* development@qt-project.org
>
> *Subject:* Re: [Development] QImage::transformed returns shallow copy for
> QTransform::TxNone matrix type.
>
> The pointer comes from external object and it's lifetime is managed by it.
> I need to ensure that I will not use it anymore after leaving certain
> function. Hence it don't even need to be thread operation, So using clean
> function won't help here.
>
> The problem here is that you can't say if transformed returns shallow or
> deep copy. Result depends on argument value. Of course the transform
> returning shallow copy on identity matrix is nice but should be documented
> somewhere. After reading docs I expected deep copy like from copy function.
> But maybe it's only me :)
>
> Thanks for profound explanation.
>
>
> 2016-07-11 12:10 GMT+01:00 Simon Hausmann :
>
>> Hi,
>>
>>
>> Thank you for the explanation of your use-case. What remains unclear to
>> me is why it is necessary for you to ensure a deep copy?
>>
>>
>> Is it related to the fact that your image is created from a raw data
>> pointer and after your worker thread is done, you cannot guarantee
>>
>> for the life-time of the raw data anymore?
>>
>>
>> Perhaps you could use the QImage constructor that takes a cleanup
>> function (and cleanupInfo pointer). If your worker thread
>>
>> ends up making a copy of the image data as a result of your
>> transformation, then your original copy can and will be deleted
>>
>> when you discard the source of the transform() call. That is something
>> that you can keep track of. Vice-versa if it's not being called,
>>
>> then you know that transformed() (or generally speaking _any_ sequence of
>> operations you may have done) still operate on a shallow
>>
>> copy. Then you can do an explicit deep copy.
>>
>>
>> Generally speaking my impression - assuming I did understand your
>> use-case correctly - is that your problem stems from the unknown
>>
>> life-cycle of your data. I don't think the behavior of
>> QImage::transformed() should be made worse for the common case where shallow
>>
>> copying benefits performance and memory consumption.
>>
>>
>> Simon
>> --
>> *From:* Development > qt...@qt-project.org> on behalf of Tomasz Olszak > >
>> *Sent:* Monday, July 11, 2016 12:53:51 PM
>> *To:* development@qt-project.org
>> *Subject:* Re: [Development] QImage::transformed returns shallow copy
>> for QTransform::TxNone matrix type.
>>
>> QImage::copy returns deep copy and has similar documentation so I assumed
>> that when docs say copy it means deep copy.
>>
>> Let's consider common case:
>>
>> 1. QImage img created from raw data pointer got from e.g. driver.
>> 2. img used in thread to perform some transforms
>> 3. Save result as deep copy
>>
>> Ensuring step 3 is most efficient and does not perform unnecessary
>> copying I need to write something like:
>>
>> QTransform t;
>> if (m.type() == QTransform::TxNone)
>> return img.copy();
>> else
>> return img.transformed(m);
>>
>> AFAIU img.transformed(m).copy() will copy twice when  m.type() !=
>> QTransform::TxNone right?
>>
>> Don't you think that is seems strange and is not documented enough?
>>
>> 2016-07-11 10:59 GMT+01:00 Simon Hausmann :
>>
>>> Hi,
>>>
>>>
>>> Could you elaborate on what you see as the discrepancy between docs and
>>> implementation? The docs don't say whether
>>>
>>> it's a shallow or a deep copy, so it looks to me that the implementation
>>> is within the bounds of the docs.
>>>
>>>
>>> Plus it seems sensible to return a shallow copy, doesn't it?
>>>
>>>
>>>
>>> Simon
>>> --
>>> *From:* Development >> qt...@qt-project.org> on behalf of Tomasz Olszak <
>>> olszak.tom...@gmail.com>
>>> *Sent:* Monday, July 11, 2016 11:38:06 AM
>>> *To:* development@qt-project.org
>>> *Subject:* [Development] QImage::transformed

Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Tomasz Olszak
QTransform m.
img.transformed(m).copy()

will create one copy. But:

QTransform m.
m.rotate(10);
img.transformed(m).copy()

will copy image twice; On embedded device, if you do some video decoding it
is a problem :)

2016-07-11 12:52 GMT+01:00 Giuseppe D'Angelo :

> On Mon, Jul 11, 2016 at 1:40 PM, Tomasz Olszak 
> wrote:
> > The problem here is that you can't say if transformed returns shallow or
> > deep copy. Result depends on argument value. Of course the transform
> > returning shallow copy on identity matrix is nice but should be
> documented
> > somewhere. After reading docs I expected deep copy like from copy
> function.
> > But maybe it's only me :)
>
> Then always deep copy and then move on with the processing? Because
> relying on shallow copies is a bit of a gamble -- by the same
> reasoning, can you be sure that setPixel(x, y, color) always detaches?
> What if it gets implemented in a way that first checks if the pixel
> already has that color, and if so, it doesn't do anything?
>
> --
> Giuseppe D'Angelo
>
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Simon Hausmann
Hi,


I realize that there may be an even simpler way of ensure that you get a deep 
copy, but only if transformed() hasn't already

made one (so that you don't have to worry about your potentially dangling 
pointer):


Instead of using copy(), why not call the non-const bits() function (and don't 
use the returned value). That will detach (and thus

deep-copy) the data if your transformation produced no copy. If a copy was 
produced, then that will be the only copy and no

copying happens.




Simon


From: Tomasz Olszak 
Sent: Monday, July 11, 2016 2:45:18 PM
To: Giuseppe D'Angelo
Cc: Simon Hausmann; development@qt-project.org
Subject: Re: [Development] QImage::transformed returns shallow copy for 
QTransform::TxNone matrix type.

QTransform m.
img.transformed(m).copy()

will create one copy. But:

QTransform m.
m.rotate(10);
img.transformed(m).copy()

will copy image twice; On embedded device, if you do some video decoding it is 
a problem :)

2016-07-11 12:52 GMT+01:00 Giuseppe D'Angelo 
mailto:dange...@gmail.com>>:
On Mon, Jul 11, 2016 at 1:40 PM, Tomasz Olszak 
mailto:olszak.tom...@gmail.com>> wrote:
> The problem here is that you can't say if transformed returns shallow or
> deep copy. Result depends on argument value. Of course the transform
> returning shallow copy on identity matrix is nice but should be documented
> somewhere. After reading docs I expected deep copy like from copy function.
> But maybe it's only me :)

Then always deep copy and then move on with the processing? Because
relying on shallow copies is a bit of a gamble -- by the same
reasoning, can you be sure that setPixel(x, y, color) always detaches?
What if it gets implemented in a way that first checks if the pixel
already has that color, and if so, it doesn't do anything?

--
Giuseppe D'Angelo

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Tomasz Olszak
Oh good spot, thanks for that. It doesn't depend on QIMage::transformed
 impl.

Thanks!

2016-07-11 13:54 GMT+01:00 Simon Hausmann :

> Hi,
>
>
> I realize that there may be an even simpler way of ensure that you get a
> deep copy, but only if transformed() hasn't already
>
> made one (so that you don't have to worry about your potentially dangling
> pointer):
>
>
> Instead of using copy(), why not call the non-const bits() function (and
> don't use the returned value). That will detach (and thus
>
> deep-copy) the data if your transformation produced no copy. If a copy was
> produced, then that will be the only copy and no
>
> copying happens.
>
>
>
>
> Simon
> --
> *From:* Tomasz Olszak 
> *Sent:* Monday, July 11, 2016 2:45:18 PM
> *To:* Giuseppe D'Angelo
> *Cc:* Simon Hausmann; development@qt-project.org
> *Subject:* Re: [Development] QImage::transformed returns shallow copy for
> QTransform::TxNone matrix type.
>
> QTransform m.
> img.transformed(m).copy()
>
> will create one copy. But:
>
> QTransform m.
> m.rotate(10);
> img.transformed(m).copy()
>
> will copy image twice; On embedded device, if you do some video decoding
> it is a problem :)
>
> 2016-07-11 12:52 GMT+01:00 Giuseppe D'Angelo :
>
>> On Mon, Jul 11, 2016 at 1:40 PM, Tomasz Olszak 
>> wrote:
>> > The problem here is that you can't say if transformed returns shallow or
>> > deep copy. Result depends on argument value. Of course the transform
>> > returning shallow copy on identity matrix is nice but should be
>> documented
>> > somewhere. After reading docs I expected deep copy like from copy
>> function.
>> > But maybe it's only me :)
>>
>> Then always deep copy and then move on with the processing? Because
>> relying on shallow copies is a bit of a gamble -- by the same
>> reasoning, can you be sure that setPixel(x, y, color) always detaches?
>> What if it gets implemented in a way that first checks if the pixel
>> already has that color, and if so, it doesn't do anything?
>>
>> --
>> Giuseppe D'Angelo
>>
>
>
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Paul Olav Tvete
On mandag 11. juli 2016 12.54.58 CEST Simon Hausmann wrote:
> Instead of using copy(), why not call the non-const bits() function (and
> don't use the returned value). That will detach [...]

Instead of using bits(), why not call detach() directly? ;)

- Paul

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Benjamin TERRIER
2016-07-11 16:03 GMT+02:00 Paul Olav Tvete :
> On mandag 11. juli 2016 12.54.58 CEST Simon Hausmann wrote:
>> Instead of using copy(), why not call the non-const bits() function (and
>> don't use the returned value). That will detach [...]
>
> Instead of using bits(), why not call detach() directly? ;)
>
> - Paul
>
> ___
> Development mailing list
> Development@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

Hi,

QImage::detach() is not public API.
However QPixmap::detach() is, so why QImage::detach() couldn't be made
public too?

BR,

Benjamin
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Simon Hausmann
Detach() is marked with \internal - wouldn't want to suggest the use of private 
api;)


Simon



From: Paul Olav Tvete
Sent: Jul 11, 2016 16:03
To: development@qt-project.org
Subject: Re: [Development] QImage::transformed returns shallow copy for 
QTransform::TxNone matrix type.

On mandag 11. juli 2016 12.54.58 CEST Simon Hausmann wrote:
> Instead of using copy(), why not call the non-const bits() function (and
> don't use the returned value). That will detach [...]

Instead of using bits(), why not call detach() directly? ;)

- Paul

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Allan Sandfeld Jensen
On Monday 11 July 2016, Benjamin TERRIER wrote:
> 2016-07-11 16:03 GMT+02:00 Paul Olav Tvete :
> > On mandag 11. juli 2016 12.54.58 CEST Simon Hausmann wrote:
> >> Instead of using copy(), why not call the non-const bits() function (and
> >> don't use the returned value). That will detach [...]
> > 
> > Instead of using bits(), why not call detach() directly? ;)
> > 
> > - Paul
> > 
> > ___
> > Development mailing list
> > Development@qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/development
> 
> Hi,
> 
> QImage::detach() is not public API.
> However QPixmap::detach() is, so why QImage::detach() couldn't be made
> public too?
> 
It probably should be. It is a lot more sensible to use than copy(rect()).

BR
`Allan
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTableView gets freezed in showing data read from SQLite database , which is updated dynamically with 2000 rows in 2s

2016-07-11 Thread André Somers



Op 09/07/2016 om 20:01 schreef swarit wipra:

Hi folks,

i have issues in showing huge data in QTableView ,data read from 
sqlite database which is being updated dynamically .. 2k rows in 2s.

i am using QSQLRelationModel
let me describe the scenario in detail.

My Qt application has a view i.e QTableView , each row has following 
structure:


 
 *QPushButton*|QLabel | QLabel | QLabel *
 
 i have created it using QItemDelegate

 each row isinserted dynamicaly , after sometime gui gets freezed.

could anyone tell me the way to fix the issue.
Don't implement it like this. You are creating 8k widgets and act 
suprised that it isn't fast... Even if you did not use QLabel but the 
default delegate, 2k push buttons is still pushing it I think.


Note that this is by no means a new issue. Search and you will find 
better options, even ones using widgets but creating far less instances.


André

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

2016-07-11 Thread Sune Vuorela
On 2016-07-11, Allan Sandfeld Jensen  wrote:
> On Monday 11 July 2016, Benjamin TERRIER wrote:
>> QImage::detach() is not public API.
>> However QPixmap::detach() is, so why QImage::detach() couldn't be made
>> public too?
>> 
> It probably should be. It is a lot more sensible to use than copy(rect()).

https://codereview.qt-project.org/#/c/164886/

/Sune

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Use of Standard Library containers in Qt source code

2016-07-11 Thread Cristian Adam
On Thu, Jul 7, 2016 at 12:06 PM, Marco Bubke  wrote:

> I think it simply a question of time to get used to the STL. You get used
> to many things.
>
> I think we should mind about the new features of C++ which are coming,
> which cannot integrated very well with Qt because we use a different idiom.
>
> I really think we should make it easier for the developer but if we
> provide no way to go the fast path do we really make it easier?
>
> If the context is changing over time, is it not smart to reevaluate
> decision again and maybe go a different route? I don't mean to do it all
> the time but maybe there is a middle path between different
> "fundamentalisms". [image: 😉]
>
Luckily there's Copper Spice, and it seems they want to be the more
*modern* C++ Qt library.

Their latest presentation

has
at page 6 this:

[image: Inline image 1]

The STL containers part is not yet done. Will they keep the move semantics
for the upcoming
containers?

What would QString refactor would bring? UTF-8? QStringView?

Cheers,
Cristian.
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Use of Standard Library containers in Qt source code

2016-07-11 Thread Thiago Macieira
On terça-feira, 12 de julho de 2016 00:20:01 PDT Cristian Adam wrote:
> Their latest presentation
>  y/copperspice_the_next_generation_of_signals.pdf> has
> at page 6 this:

Criticism:
* Qt's dependency on qmake: that's only for building Qt itself, not for your 
application. Otherwise, we could always criticise any library for choosing to 
use buildsystem X instead of Y.

* Remove moc: why? Moc has a very important use besides signals, that being of 
reflection of C++. Until at least C++ 2020, but most likely WAY further, 
there's no replacement for that. Therefore, removing moc is removing important 
functionality. Let's see CS implement QtScript, QtDBus and QtQml without 
moc...

* Use native C++ atomics: done in Qt 5.7, except for MSVC which doesn't 
implement it properly.

* Signal / slot delivery as a separate library: interesting, I'll give CS 
that, but not sure what the value of this is.

* Containers: leveraging STL only makes sense if we drop implicit sharing. 
There are many arguments in favour and against doing that, which I will not 
get into. What I will say: doing implicit-sharing with STL is the worst of 
both worlds.

* Use C++ native pointers: granted, that's also the reason why we're not 
reimplementing std::unique_ptr or extending QScopedPointer to have move 
semantics.

* Refactor QString: huh?

> What would QString refactor would bring? UTF-8? QStringView?

Why would we want UTF-8? There's no native type for it, unlike UTF-16's 
char16_t. And ALL the good Unicode-capable API in most OSes uses UTF-16 (Java, 
ICU, Win32, Cocoa, all are UTF-16; POSIX's wide-char API is neither good nor 
guaranteed to be UTF-32).

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development