Re: [Lazarus] Order of OnCreate and OnActivate in Qt4

2018-11-26 Thread Vojtěch Čihák via lazarus

Thanks, Kostas, especially part about Qt styling.
 
I answered my solution yesterday, but it didn't appear in ML, it went to zejlko 
only - I noticed later. So here it is:
 
I don't have QtNativeEventFilter in qtdefines.inc at all.
However, I found simple workaround. I create main form with Visible:=False; and 
when all other forms are created I do FrmMain.Show; (in *.lpr). The order of 
events is as expected.
 
Thanks.
 
__

Od: "Kostas Michalopoulos via lazarus" 
Komu: "Lazarus mailing list" 
Datum: 26.11.2018 11:32
Předmět: Re: [Lazarus] Order of OnCreate and OnActivate in Qt4


I wouldn't rely on event order as anything between the creation to 
Application.Run could call Application.ProcessMessages - including some 
components/controls you may be using. As a rule of thumb you should assume that 
after calling a control (or form) that it can start receiving events.In Qt4 
styling is done through native code (QStyle subclasses) and it can alter 
widgets (QStyle::polish) so it isn't unthinkable that a theme could do 
something that generates events.
On Sun, Nov 25, 2018 at 6:47 PM zeljko via lazarus > wrote:On 11/25/2018 04:43 PM, Vojtěch Čihák via 
lazarus wrote:

> CRASH, because code in OnActivate assumes that FrmContext already exists.
> 
> So, Qt4+Plastique has different order of events than Qt4+QtCurve.
> 
> Unfortunately, I cannot reproduce with simple demo.
> 
> What I'm doing wrong? Do I rely on something that is not guaranteed?


Try to disable usage of QtNativeEventFilter in qtdefines.inc if it's 
enabled.


zeljko
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org 
https://lists.lazarus-ide.org/listinfo/lazarus 


--

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus 


-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Order of OnCreate and OnActivate in Qt4

2018-11-26 Thread Kostas Michalopoulos via lazarus
I wouldn't rely on event order as anything between the creation to
Application.Run could call Application.ProcessMessages - including some
components/controls you may be using. As a rule of thumb you should assume
that after calling a control (or form) that it can start receiving events.

In Qt4 styling is done through native code (QStyle subclasses) and it can
alter widgets (QStyle::polish) so it isn't unthinkable that a theme could
do something that generates events.


On Sun, Nov 25, 2018 at 6:47 PM zeljko via lazarus <
lazarus@lists.lazarus-ide.org> wrote:

> On 11/25/2018 04:43 PM, Vojtěch Čihák via lazarus wrote:
>
> > CRASH, because code in OnActivate assumes that FrmContext already exists.
> >
> > So, Qt4+Plastique has different order of events than Qt4+QtCurve.
> >
> > Unfortunately, I cannot reproduce with simple demo.
> >
> > What I'm doing wrong? Do I rely on something that is not guaranteed?
>
> Try to disable usage of QtNativeEventFilter in qtdefines.inc if it's
> enabled.
>
> zeljko
> --
> ___
> lazarus mailing list
> lazarus@lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
>
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Order of OnCreate and OnActivate in Qt4

2018-11-25 Thread zeljko via lazarus

On 11/25/2018 04:43 PM, Vojtěch Čihák via lazarus wrote:


CRASH, because code in OnActivate assumes that FrmContext already exists.

So, Qt4+Plastique has different order of events than Qt4+QtCurve.

Unfortunately, I cannot reproduce with simple demo.

What I'm doing wrong? Do I rely on something that is not guaranteed?


Try to disable usage of QtNativeEventFilter in qtdefines.inc if it's 
enabled.


zeljko
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Order of OnCreate and OnActivate in Qt4

2018-11-25 Thread zeljko via lazarus

On 11/25/2018 04:43 PM, Vojtěch Čihák via lazarus wrote:

Today I used tool qtconfig and changed style (Appearance) from Plastique 
to QtCurve. Now my code crashes, order of events is:


FrmMain.Create

FrmMain.Activate

CRASH, because code in OnActivate assumes that FrmContext already exists.

So, Qt4+Plastique has different order of events than Qt4+QtCurve.

Unfortunately, I cannot reproduce with simple demo.

What I'm doing wrong? Do I rely on something that is not guaranteed?


Afaik not, that should work w/o problems. Never seen such kind of 
problem with different themes. In any case, without example project I 
cannot help.


zeljko
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Order of OnCreate and OnActivate in Qt4

2018-11-25 Thread Vojtěch Čihák via lazarus

Hi,
 
I met strange bug today. I have these lines in .lpr:
...
Application.CreateForm(TFrmMain, FrmMain);
...
Application.CreateForm(TFrmContext, FrmContext);
...
 
and the order of events in Qt and GTk2 is:
FrmMain.Create
FrmContext.Create
FrmMain.Activate
 
Today I used tool qtconfig and changed style (Appearance) from Plastique to 
QtCurve. Now my code crashes, order of events is:
FrmMain.Create
FrmMain.Activate
CRASH, because code in OnActivate assumes that FrmContext already exists.
 
So, Qt4+Plastique has different order of events than Qt4+QtCurve.
Unfortunately, I cannot reproduce with simple demo.
 
What I'm doing wrong? Do I rely on something that is not guaranteed?
 
Thanks.

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus