summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Menteiro de Carvalho <sekelsenmat@users.sourceforge.net>2007-05-17 05:55:12 +0000
committerFelipe Menteiro de Carvalho <sekelsenmat@users.sourceforge.net>2007-05-17 05:55:12 +0000
commitfe73e95e263dbffa96386ab1aa2b3cd7a78e66dc (patch)
treeab3573d1bf29ff93c421fb893172579c33c61ceb
parent866f4fc3e3b682cae67091413d18c62bb5cdddd3 (diff)
downloadfpGUI-fe73e95e263dbffa96386ab1aa2b3cd7a78e66dc.tar.xz
Improved form freeing code and general handling of GFApplication.Forms
-rw-r--r--examples/gui/helloworld/helloworld.lpi9
-rw-r--r--examples/gui/helloworld/helloworld.pas1
-rw-r--r--examples/gui/widgettest/widgettest.lpi8
-rw-r--r--gfx/gdi/gfx_gdi.pas18
-rw-r--r--gfx/gfxbase.pas10
-rw-r--r--gfx/x11/gfx_x11.pas2
-rw-r--r--gui/fpguiform.inc6
7 files changed, 33 insertions, 21 deletions
diff --git a/examples/gui/helloworld/helloworld.lpi b/examples/gui/helloworld/helloworld.lpi
index e0302f2b..9ebe89bc 100644
--- a/examples/gui/helloworld/helloworld.lpi
+++ b/examples/gui/helloworld/helloworld.lpi
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="/"/>
+ <PathDelim Value="\"/>
<Version Value="5"/>
<General>
<Flags>
@@ -9,7 +9,7 @@
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
- <IconPath Value="./"/>
+ <IconPath Value=".\"/>
<TargetFileExt Value=""/>
</General>
<PublishOptions>
@@ -20,7 +20,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@@ -38,8 +38,9 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
+ <PathDelim Value="\"/>
<SearchPaths>
- <OtherUnitFiles Value="../../src/"/>
+ <OtherUnitFiles Value="..\..\src\"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
diff --git a/examples/gui/helloworld/helloworld.pas b/examples/gui/helloworld/helloworld.pas
index bbcfd99b..5e139fff 100644
--- a/examples/gui/helloworld/helloworld.pas
+++ b/examples/gui/helloworld/helloworld.pas
@@ -60,3 +60,4 @@ begin
MainForm.Free;
end;
end.
+
diff --git a/examples/gui/widgettest/widgettest.lpi b/examples/gui/widgettest/widgettest.lpi
index be425d5c..82a0b3e5 100644
--- a/examples/gui/widgettest/widgettest.lpi
+++ b/examples/gui/widgettest/widgettest.lpi
@@ -1,15 +1,16 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="/"/>
+ <PathDelim Value="\"/>
<Version Value="5"/>
<General>
<Flags>
<SaveOnlyProjectUnits Value="True"/>
+ <AlwaysBuild Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
- <IconPath Value="./"/>
+ <IconPath Value=".\"/>
<TargetFileExt Value=""/>
</General>
<PublishOptions>
@@ -20,7 +21,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@@ -39,6 +40,7 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
+ <PathDelim Value="\"/>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
diff --git a/gfx/gdi/gfx_gdi.pas b/gfx/gdi/gfx_gdi.pas
index ddbc1d1b..7964f222 100644
--- a/gfx/gdi/gfx_gdi.pas
+++ b/gfx/gdi/gfx_gdi.pas
@@ -1020,8 +1020,7 @@ begin
Windows.ReleaseDC(0, TempDC);
end;
-function TGDIScreen.CreateMonoBitmapCanvas(AWidth, AHeight: Integer
- ): TFCustomCanvas;
+function TGDIScreen.CreateMonoBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas;
var
TempDC: HDC;
begin
@@ -1040,13 +1039,10 @@ begin
end;
+{ Itīs not the job of the Application object to clean up undestroyed forms
+ This can generate crashes }
destructor TGDIApplication.Destroy;
-var
- i: Integer;
begin
- for i := 0 to Forms.Count - 1 do
- TGDIWindow(Forms[i]).Free;
-
inherited Destroy;
end;
@@ -1156,11 +1152,15 @@ begin
Event.EventType := etShow;
Window.ProcessEvent(Event);
+
+ GFApplication.AddWindow(Window);
end
else
begin
Event.EventType := etHide;
Window.ProcessEvent(Event);
+
+ GFApplication.RemoveWindow(Window);
end;
end;
WM_Move:
@@ -1406,10 +1406,10 @@ begin
Windows.DestroyWindow(OldHandle);
end;
- GFApplication.Forms.Remove(Self);
+ GFApplication.RemoveWindow(Self);
// Are we the last window for our owning application?
- if GFApplication.Forms.Count = 0 then
+ if (GFApplication.QuitWhenLastWindowCloses and (GFApplication.Forms.Count = 0)) then
Windows.PostQuitMessage(0);
inherited Destroy;
diff --git a/gfx/gfxbase.pas b/gfx/gfxbase.pas
index 04212b2f..be5a31fd 100644
--- a/gfx/gfxbase.pas
+++ b/gfx/gfxbase.pas
@@ -1361,13 +1361,21 @@ end;
procedure TFCustomApplication.AddWindow(AWindow: TFCustomWindow);
begin
+{$IFDEF VerboseFPGUI}
+ WriteLn('[TFCustomApplication.AddWindow] Window Title: ', AWindow.Title);
+{$ENDIF}
+
if Forms.IndexOf(AWindow) = -1 then
Forms.Add(AWindow);
end;
procedure TFCustomApplication.RemoveWindow(AWindow: TFCustomWindow);
begin
- Forms.Remove(AWindow);
+{$IFDEF VerboseFPGUI}
+ WriteLn('[TFCustomApplication.RemoveWindow] Window Title: ', AWindow.Title);
+{$ENDIF}
+
+ if (Assigned(Forms) and Assigned(AWindow)) then Forms.Remove(AWindow);
end;
procedure TFCustomApplication.Run;
diff --git a/gfx/x11/gfx_x11.pas b/gfx/x11/gfx_x11.pas
index 1a9d2228..ad50f149 100644
--- a/gfx/x11/gfx_x11.pas
+++ b/gfx/x11/gfx_x11.pas
@@ -1438,7 +1438,7 @@ begin
GFApplication.DirtyList.ClearQueueForWindow(Self);
- GFApplication.Forms.Remove(Self);
+ GFApplication.RemoveWindow(Self);
XDestroyWindow(GFApplication.Handle, Handle);
diff --git a/gui/fpguiform.inc b/gui/fpguiform.inc
index 9bd737da..5c3b3c06 100644
--- a/gui/fpguiform.inc
+++ b/gui/fpguiform.inc
@@ -133,7 +133,9 @@ begin
OnDestroy(Self);
if Assigned(FWnd) then
FWnd.Free;
- GFApplication.Forms.Remove(Self);
+
+// GFApplication.Forms.Remove(Self);
+
inherited Destroy;
end;
@@ -143,7 +145,6 @@ begin
LAYOUTTRACE('TFCustomForm.Show for %s:%s', [Name, ClassName]);
FVisible := True;
- GFApplication.AddWindow(Wnd);
Wnd.Show;
end;
@@ -157,7 +158,6 @@ procedure TFCustomForm.Close;
begin
LAYOUTTRACE('TFCustomForm.Close for %s:%s', [Name, ClassName]);
- GFApplication.RemoveWindow(FWnd);
FVisible := False;
FWnd.Free;