Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2007-07

Todays commit

9 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Paul Ishenin

Hello, Items specific to the Qt widget set.

I've tried to understand what can cause memory corruption. My first assumption was that Qt events can be fired while Widget destroying. So I moved all event creation code to TQtWidget.AttachEvents and all event destuction code to TQtWidget.DetachEvents.

Before Widget destruction I call DetachEvents to ensure that no events will be fired during death process.

Please you dislike it then revert commit. As for
me, code became more beautiful without repeating of event attaching stuff in various units.

But this did not help with memory corruption.

While experiments I've catched exception in TQtWSCustomControl.ShowHide in this part

if not AWinControl.InheritsFrom(TCustomForm) then
   TQtAbstractScrollArea(AWinControl.Handle).viewportNeeded;

After replacing it with

if Widget is TQtAbstractScrollArea then
   TQtAbstractScrollArea(Widget).viewportNeeded;

memory corruption is gone.

So, I think such replacemennts can be done in all code where we looking at LCL component, but doing cast of TQtWidget.

I also commited TQtCaret, but disabled it work through check how this changes will affect your test (or work) applications.

ps:
I will not be available for monday morning, so fell free to revert commit if something will work wrong.

Best regards, Paul Ishenin.
zeljko
to Paul Ishenin
Paul Ishenin wrote 13 lines
Hello, Items specific to the Qt widget set. I've tried to understand what can cause memory corruption. My first assumption was that Qt events can be fired while Widget destroying. So I moved all event creation code to TQtWidget.AttachEvents and all event destuction code to TQtWidget.DetachEvents. Before Widget destruction I call DetachEvents to ensure that no events will be fired during death process. Please you dislike it then revert commit. As for me, code became more beautiful without repeating of event attaching stuff in various units.

This is what gdb says about today's commit:

Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0x004fb67e in QTreeWidget_hook_destroy () from /usr/lib/libqt4intf.so #2 0x081a0ed7 in TQTTREEWIDGET__DETACHEVENTS (this=0x4030c088) at qtwidgets.pas:4355
#3 0x081a0a22 in TQTTREEVIEW__DESTROY (vmt=0x0, this=0x4030c088) at qtwidgets.pas:4223
#4 0x081a0bed in TQTTREEWIDGET__DESTROY (vmt=0x1, this=0x4030c088) at qtwidgets.pas:4284
#5 0x0805bcd9 in SYSTEM_TOBJECT_$__FREE ()
#6 0x08192950 in TQTWSCUSTOMLISTVIEW__DESTROYHANDLE (AWINCONTROL=0x400baef8, pvmt=0x4008d418) at qtwscomctrls.pp:765
#7 0x0812087f in TWINCONTROL__DESTROYWND (this=0x400baef8) at wincontrol.inc:5495
#8 0x080d6eba in TCUSTOMLISTVIEW__DESTROYWND (this=0x400baef8) at customlistview.inc:554
#9 0x0811ce18 in TWINCONTROL__DESTROYHANDLE (this=0x400baef8) at wincontrol.inc:3418
#10 0x0811ce03 in TWINCONTROL__DESTROYHANDLE (this=0x400b7228) at wincontrol.inc:3415
#11 0x08070932 in TCUSTOMFORM__SHOWMODAL (this=0x400b7228) at customform.inc:1992
#12 0x08077678 in TFORM1__MENUITEM2CLICK (SENDER=0x4009c208, this=0x400b66e8) at unit1.pas:132
#13 0x081a1a86 in TQTMENU__SLOTTRIGGERED (CHECKED=false, this=0x40002668) at qtwidgets.pas:4762
#14 0x0050ddd5 in QAction_hook::triggered_hook () from /usr/lib/libqt4intf.so #15 0x004f5f1d in QAction_hook::qt_metacall () from /usr/lib/libqt4intf.so #16 0x0038606f in QMetaObject::activate () from /usr/lib/libQtCore.so.4 #17 0x0038631a in QMetaObject::activate () from /usr/lib/libQtCore.so.4 #18 0x067235db in QAction::triggered () from /usr/lib/libQtGui.so.4 #19 0x067238b2 in QAction::activate () from /usr/lib/libQtGui.so.4 #20 0x06a8c3d8 in QMenuPrivate::activateAction () from /usr/lib/libQtGui.so.4 #21 0x06a8ea16 in QMenu::mouseReleaseEvent () from /usr/lib/libQtGui.so.4 #22 0x0676bafd in QWidget::event () from /usr/lib/libQtGui.so.4 #23 0x06a89d27 in QMenu::event () from /usr/lib/libQtGui.so.4 #24 0x06728d1b in QApplicationPrivate::notify_helper () from /usr/lib/libQtGui.so.4
#25 0x06729a00 in QApplication::notify () from /usr/lib/libQtGui.so.4 #26 0x00376c60 in QCoreApplication::notifyInternal () from /usr/lib/libQtCore.so.4
#27 0x06782e31 in QETWidget::translateMouseEvent () from /usr/lib/libQtGui.so.4
#28 0x06781a5e in QApplication::x11ProcessEvent () from /usr/lib/libQtGui.so.4 #29 0x067a38c2 in
QGuiEventDispatcherGlibPrivate::QGuiEventDispatcherGlibPrivate () from /usr/lib/libQtGui.so.4
#30 0x02c3418b in g_main_dispatch (context=0x9db92d0) at gmain.c:1934 #31 0x02c35248 in g_main_context_dispatch (context=0x9db92d0) at gmain.c:2484 ---Type <return> to continue, or q <return> to quit--- #32 0x02c3557c in g_main_context_iterate (context=0x9db92d0, block=1, dispatch=1, self=0x9db8318) at gmain.c:2565
#33 0x02c357dc in g_main_context_iteration (context=0x9db92d0, may_block=0) at gmain.c:2624
#34 0x00397aea in QEventDispatcherGlib::processEvents () from /usr/lib/libQtCore.so.4
#35 0x067a33df in QGuiEventDispatcherGlib::processEvents () from /usr/lib/libQtGui.so.4
#36 0x0037631c in QEventLoop::processEvents () from /usr/lib/libQtCore.so.4 #37 0x003764b0 in QEventLoop::exec () from /usr/lib/libQtCore.so.4 #38 0x0037a724 in QCoreApplication::exec () from /usr/lib/libQtCore.so.4 #39 0x0672834d in QApplication::exec () from /usr/lib/libQtGui.so.4 #40 0x004b071c in QApplication_exec () from /usr/lib/libqt4intf.so #41 0x0818a9c1 in TQTWIDGETSET__APPRUN (ALOOP=0x8074880 <TAPPLICATION__RUNLOOP>, this=0x40013788) at qtobject.inc:102 #42 0x0807486c in TAPPLICATION__RUN (this=0x400a4028) at application.inc:1033 #43 0x08051db5 in main () at project1.lpr:13

zeljko

Paul Ishenin
to zeljko
zeljko wrote 8 lines
This is what gdb says about today's commit: Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x004fb67e in QTreeWidget_hook_destroy () from /usr/lib/libqt4intf.so #2 0x081a0ed7 in TQTTREEWIDGET__DETACHEVENTS (this=0x4030c088) at

Very unexpected for me :( I've added more checks before detachevents. Please retest. And since I have another line numbers can you tell me what exactly is written in QtWidgets.pas at that line?

Best regards,
Paul Ishenin.

zeljko
to Paul Ishenin
Paul Ishenin wrote 13 lines
zeljko wrote: > This is what gdb says about today's commit: > > Program received signal SIGSEGV, Segmentation fault. > 0x00000000 in ?? () > (gdb) bt > #0 0x00000000 in ?? () > #1 0x004fb67e in QTreeWidget_hook_destroy () from /usr/lib/libqt4intf.so > #2 0x081a0ed7 in TQTTREEWIDGET__DETACHEVENTS (this=0x4030c088) at Very unexpected for me :( I've added more checks before detachevents. Please retest. And since I have another line numbers can you tell me what exactly is written in QtWidgets.pas at that line?
procedure TQtTreeWidget.DetachEvents;
begin
  QTreeWidget_hook_destroy(FCurrentItemChangedHook);
  QTreeWidget_hook_destroy(FItemDoubleClickedHook);
  QTreeWidget_hook_destroy(FItemClickedHook);
  QTreeWidget_hook_destroy(FItemActivatedHook);
  QTreeWidget_hook_destroy(FItemChangedHook);
  QTreeWidget_hook_destroy(FItemSelectionChangedHook);
  QTreeWidget_hook_destroy(FItemPressedHook);
  QTreeWidget_hook_destroy(FItemEnteredHook);
  inherited DetachEvents;
end;

if I comment code like this then we have no AV's

procedure TQtTreeWidget.DetachEvents;
begin
(*
  QTreeWidget_hook_destroy(FCurrentItemChangedHook);
  QTreeWidget_hook_destroy(FItemDoubleClickedHook);
  QTreeWidget_hook_destroy(FItemClickedHook);
  QTreeWidget_hook_destroy(FItemActivatedHook);
  QTreeWidget_hook_destroy(FItemChangedHook);
  QTreeWidget_hook_destroy(FItemSelectionChangedHook);
  QTreeWidget_hook_destroy(FItemPressedHook);
  QTreeWidget_hook_destroy(FItemEnteredHook);
*)
  inherited DetachEvents;
end;

Paul , did U test your code under linux or just under Windows ? I've test this under FC4 and FC7 and got same result.

Paul Ishenin
to zeljko
zeljko wrote 34 lines
procedure TQtTreeWidget.DetachEvents; begin QTreeWidget_hook_destroy(FCurrentItemChangedHook); QTreeWidget_hook_destroy(FItemDoubleClickedHook); QTreeWidget_hook_destroy(FItemClickedHook); QTreeWidget_hook_destroy(FItemActivatedHook); QTreeWidget_hook_destroy(FItemChangedHook); QTreeWidget_hook_destroy(FItemSelectionChangedHook); QTreeWidget_hook_destroy(FItemPressedHook); QTreeWidget_hook_destroy(FItemEnteredHook); inherited DetachEvents; end; if I comment code like this then we have no AV's procedure TQtTreeWidget.DetachEvents; begin (* QTreeWidget_hook_destroy(FCurrentItemChangedHook); QTreeWidget_hook_destroy(FItemDoubleClickedHook); QTreeWidget_hook_destroy(FItemClickedHook); QTreeWidget_hook_destroy(FItemActivatedHook); QTreeWidget_hook_destroy(FItemChangedHook); QTreeWidget_hook_destroy(FItemSelectionChangedHook); QTreeWidget_hook_destroy(FItemPressedHook); QTreeWidget_hook_destroy(FItemEnteredHook); *) inherited DetachEvents; end; Paul , did U test your code under linux or just under Windows ? I've test this under FC4 and FC7 and got same result.

Only under windows. Btw, have you updated after my mail? What fpc version do you have (I have fixes_2_2 branch)? Can you also check if TQtTreeWidget.AttachEvents will be called?

Best regards,
Paul Ishenin.

zeljko
to Paul Ishenin
Paul Ishenin wrote
Only under windows. Btw, have you updated after my mail? What fpc version do you have (I have fixes_2_2 branch)? Can you also check if TQtTreeWidget.AttachEvents will be called?

2.0.4-20070628 , yesterday tried with 2.0.4-20070711 but got same errors. how to get fixes_2_2_branch ?

tnx
zeljko

Paul Ishenin
to zeljko: 2.0.4-20070628 , yesterday tried with 2.0.4-20070711 but got same errors. how to get…

zeljko ?????:

Show quoted text 8 lines
On Thursday 12 July 2007 09:33, Paul Ishenin wrote: > Only under windows. Btw, have you updated after my mail? What fpc > version do you have (I have fixes_2_2 branch)? Can you also check if > TQtTreeWidget.AttachEvents will be called? 2.0.4-20070628 , yesterday tried with 2.0.4-20070711 but got same errors. how to get fixes_2_2_branch ?

something like this:
svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_2

Best regards,
Paul Ishenin.

zeljko
to Paul Ishenin
Paul Ishenin wrote 11 lines
zeljko ?????: > On Thursday 12 July 2007 09:33, Paul Ishenin wrote: >> Only under windows. Btw, have you updated after my mail? What fpc >> version do you have (I have fixes_2_2 branch)? Can you also check if >> TQtTreeWidget.AttachEvents will be called? > > 2.0.4-20070628 , yesterday tried with 2.0.4-20070711 but got same errors. > how to get fixes_2_2_branch ? something like this: svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_2

I've recompiled code with fixes_2_2 and got same result under linux.

[linda at houston fpc]$ ppc386
Free Pascal Compiler version 2.1.5 [2007/07/12] for i386 Copyright (c) 1993-2007 by Florian Klaempfl
/usr/lib/fpc/2.1.5/ppc386 [options] <inputfile> [options]

zeljko