mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 20:39:25 +02:00
fix qt crashes
git-svn-id: trunk@13808 -
This commit is contained in:
parent
85f883a250
commit
fea0888a37
@ -2391,12 +2391,14 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function FindOwnerControl(Handle: hwnd): TWinControl;
|
||||
begin
|
||||
While Handle<>0 do begin
|
||||
Result:=FindControl(Handle);
|
||||
if Result<>nil then exit;
|
||||
Handle:=GetParent(Handle);
|
||||
while Handle<>0 do
|
||||
begin
|
||||
Result := FindControl(Handle);
|
||||
if Result <> nil then
|
||||
Exit;
|
||||
Handle := GetParent(Handle);
|
||||
end;
|
||||
Result:=nil;
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -977,7 +977,7 @@ end;
|
||||
TControl.Perform
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
Function TControl.Perform(Msg:Cardinal; WParam: WParam; LParam: LParam): LRESULT;
|
||||
function TControl.Perform(Msg:Cardinal; WParam: WParam; LParam: LParam): LRESULT;
|
||||
var
|
||||
Message : TLMessage;
|
||||
begin
|
||||
@ -1014,7 +1014,7 @@ end;
|
||||
{------------------------------------------------------------------------------
|
||||
TControl.ScreenToClient
|
||||
------------------------------------------------------------------------------}
|
||||
Function TControl.ScreenToClient(const APoint: TPoint): TPoint;
|
||||
function TControl.ScreenToClient(const APoint: TPoint): TPoint;
|
||||
var
|
||||
P : TPoint;
|
||||
begin
|
||||
@ -1024,9 +1024,9 @@ begin
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function TControl.ClientToScreen(const APoint: TPoint): TPoint;
|
||||
function TControl.ClientToScreen(const APoint: TPoint): TPoint;
|
||||
------------------------------------------------------------------------------}
|
||||
Function TControl.ClientToScreen(const APoint: TPoint): TPoint;
|
||||
function TControl.ClientToScreen(const APoint: TPoint): TPoint;
|
||||
var
|
||||
P : TPoint;
|
||||
begin
|
||||
@ -1217,7 +1217,7 @@ end;
|
||||
{------------------------------------------------------------------------------
|
||||
TControl GetMouseCapture
|
||||
------------------------------------------------------------------------------}
|
||||
Function TControl.GetMouseCapture : Boolean;
|
||||
function TControl.GetMouseCapture : Boolean;
|
||||
Begin
|
||||
Result := GetCaptureControl = Self;
|
||||
end;
|
||||
@ -2484,7 +2484,7 @@ end;
|
||||
{------------------------------------------------------------------------------
|
||||
TControl IsCaptionStored
|
||||
------------------------------------------------------------------------------}
|
||||
Function TControl.IsCaptionStored : Boolean;
|
||||
function TControl.IsCaptionStored : Boolean;
|
||||
Begin
|
||||
Result := (ActionLink = nil) or not ActionLink.IsCaptionLinked;
|
||||
end;
|
||||
|
@ -55,7 +55,6 @@ type
|
||||
TheObject: QObjectH;
|
||||
constructor Create; virtual;
|
||||
destructor Destroy; override;
|
||||
function CanPostponeFree: Boolean; virtual;
|
||||
procedure Release; virtual;
|
||||
public
|
||||
procedure AttachEvents; virtual;
|
||||
@ -590,41 +589,21 @@ end;
|
||||
|
||||
destructor TQtObject.Destroy;
|
||||
begin
|
||||
//WriteLn('destroying: ', PtrUInt(Self), ' : ', ClassName);
|
||||
if TheObject <> nil then
|
||||
begin
|
||||
DetachEvents;
|
||||
QObject_destroy(TheObject);
|
||||
QObject_deleteLater(TheObject);
|
||||
TheObject := nil;
|
||||
end;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TQtObject.CanPostponeFree: Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TQtObject.Release;
|
||||
var
|
||||
AEvent: QLCLMessageEventH;
|
||||
begin
|
||||
{WriteLn('Release: ', PtrUInt(Self), ' : ', ClassName);
|
||||
DumpStack;}
|
||||
if CanPostponeFree then
|
||||
begin
|
||||
AEvent := QLCLMessageEvent_create(LCLQt_Destroy);
|
||||
QLCLMessageEvent_setWParam(AEvent, PtrUInt(Self));
|
||||
QCoreApplication_postEvent(QCoreApplication_instance(), AEvent {$IFDEF USE_QT_4_3}, Ord(QtLowEventPriority) {$ENDIF});
|
||||
//WriteLn('Posted release event');
|
||||
end
|
||||
if InEvent then
|
||||
FReleaseInEvent := True
|
||||
else
|
||||
begin
|
||||
if InEvent then
|
||||
FReleaseInEvent := True
|
||||
else
|
||||
Free;
|
||||
end;
|
||||
Free;
|
||||
end;
|
||||
|
||||
procedure TQtObject.AttachEvents;
|
||||
|
@ -118,7 +118,6 @@ type
|
||||
|
||||
destructor Destroy; override;
|
||||
function GetContainerWidget: QWidgetH; virtual;
|
||||
function CanPostponeFree: Boolean; override;
|
||||
procedure Release; override;
|
||||
public
|
||||
function DeliverMessage(var Msg): LRESULT; virtual;
|
||||
@ -1192,10 +1191,10 @@ begin
|
||||
{$endif}
|
||||
|
||||
// set Handle->QWidget map
|
||||
AVariant := QVariant_Create(Int64(ptruint(Self)));
|
||||
QObject_setProperty(QObjectH(Widget), 'lclwidget', AVariant);
|
||||
AVariant := QVariant_Create(Int64(PtrUInt(Self)));
|
||||
QObject_setProperty(Widget, 'lclwidget', AVariant);
|
||||
|
||||
fillchar(FPaintData, sizeOf(FPaintData), 0);
|
||||
FillChar(FPaintData, sizeOf(FPaintData), 0);
|
||||
|
||||
// Sets it's initial properties
|
||||
|
||||
@ -1218,18 +1217,16 @@ begin
|
||||
DetachEvents;
|
||||
|
||||
QVariant_destroy(AVariant);
|
||||
if Widget <> nil then
|
||||
QObject_setProperty(Widget, 'lclwidget', QVariant_create(QVariantInvalid));
|
||||
|
||||
{$ifdef VerboseQt}
|
||||
WriteLn('Calling QWidget_destroy');
|
||||
{$endif}
|
||||
|
||||
QCursor_destroy(FDefaultCursor);
|
||||
|
||||
if HasCaret then
|
||||
DestroyCaret;
|
||||
|
||||
|
||||
if (Widget <> nil) and FOwnWidget then
|
||||
QWidget_destroy(QWidgetH(Widget));
|
||||
QObject_deleteLater(Widget);
|
||||
Widget := nil;
|
||||
end;
|
||||
|
||||
@ -1294,11 +1291,6 @@ begin
|
||||
Result := Widget;
|
||||
end;
|
||||
|
||||
function TQtWidget.CanPostponeFree: Boolean;
|
||||
begin
|
||||
Result := not Application.Terminated;
|
||||
end;
|
||||
|
||||
procedure TQtWidget.Release;
|
||||
begin
|
||||
LCLObject := nil;
|
||||
@ -3502,7 +3494,8 @@ begin
|
||||
if Widget <> nil then
|
||||
begin
|
||||
DetachEvents;
|
||||
QWidget_destroy(Widget);
|
||||
QObject_setProperty(Widget, 'lclwidget', QVariant_create(QVariantInvalid));
|
||||
QObject_deleteLater(Widget);
|
||||
Widget := nil;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user