Skip to content

Commit e5c0ce6

Browse files
committed
Merge branch 'release/4.24.1'
Release v4.24.1
2 parents 620c157 + c6274e0 commit e5c0ce6

File tree

8 files changed

+80
-16
lines changed

8 files changed

+80
-16
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Releases are listed in reverse version number order.
66

77
> Note that _CodeSnip_ v4 was developed in parallel with v3 for a while. As a consequence some v3 releases have later release dates than early v4 releases.
88
9+
## Release v4.24.1 of 13 April 2005
10+
11+
* Fixed bug where CodeSnip occasionally crashes after a computer resumes from hibernation [issue #70].
12+
* Bumped some copyright dates for 2025.
13+
914
## Release v4.24.0 of 23 October 2024
1015

1116
* Compilers with which a snippet has not been tested are now omitted from snippet information that is copied to the clipboard and included in print outs [issue #143].

Diff for: Docs/License.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22

33
<!--
4-
* Copyright (C) 2012-2024, Peter Johnson (gravatar.com/delphidabbler).
4+
* Copyright (C) 2012-2025, Peter Johnson (gravatar.com/delphidabbler).
55
*
66
* CodeSnip license.
77
*
@@ -231,7 +231,7 @@ <h2>
231231
Executable Program
232232
</h2>
233233
<p>
234-
DelphiDabbler <em>CodeSnip</em> is copyright &copy; 2005-2024 by <a
234+
DelphiDabbler <em>CodeSnip</em> is copyright &copy; 2005-2025 by <a
235235
href="https://gravatar.com/delphidabbler"
236236
>Peter D Johnson</a>.
237237
</p>
@@ -1801,7 +1801,7 @@ <h2 id="ddab-exclusive">
18011801
</h2>
18021802

18031803
<p>
1804-
Files covered by this license are original work, copyright &copy; 2012-2024, <a href="https://gravatar.com/delphidabbler">Peter D Johnson</a>.
1804+
Files covered by this license are original work, copyright &copy; 2012-2025, <a href="https://gravatar.com/delphidabbler">Peter D Johnson</a>.
18051805
</p>
18061806

18071807
<p>

Diff for: Src/FmMain.pas

+23-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at https://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2005-2024, Peter Johnson (gravatar.com/delphidabbler).
6+
* Copyright (C) 2005-2025, Peter Johnson (gravatar.com/delphidabbler).
77
*
88
* Application's main form. Handles the program's main window display and user
99
* interaction.
@@ -522,6 +522,11 @@ TMainForm = class(THelpAwareForm)
522522
/// <summary>Object that manages favourites.</summary>
523523
fFavouritesMgr: TFavouritesManager;
524524

525+
/// <summary>Handles the <c>WM_POWERBROADCAST</c> messages to detect and
526+
/// respond to hibernation messages.</summary>
527+
/// <remarks>This is necessary as part of the fix for an obscure bug. See
528+
/// https://github.com/delphidabbler/codesnip/issues/70</remarks>
529+
procedure WMPowerBroadcast(var Msg: TMessage); message WM_POWERBROADCAST;
525530
/// <summary>Displays view item given by TViewItemAction instance
526531
/// referenced by Sender and adds to history list.</summary>
527532
procedure ActViewItemExecute(Sender: TObject);
@@ -1324,7 +1329,6 @@ procedure TMainForm.FormDestroy(Sender: TObject);
13241329
// fStatusBarMgr MUST be nilled: otherwise it can be called after status bar
13251330
// control has been freed and so cause AV when trying to use the control
13261331
FreeAndNil(fStatusBarMgr);
1327-
13281332
end;
13291333

13301334
procedure TMainForm.FormResize(Sender: TObject);
@@ -1514,7 +1518,6 @@ procedure TMainForm.InitForm;
15141518
// Create object to handle compilation and assoicated UI and dialogues
15151519
fCompileMgr := TMainCompileMgr.Create(Self); // auto-freed
15161520

1517-
15181521
// Set event handler for snippets database
15191522
Database.AddChangeEventHandler(DBChangeHandler);
15201523

@@ -1582,5 +1585,22 @@ procedure TMainForm.splitVertCanResize(Sender: TObject;
15821585
Accept := False;
15831586
end;
15841587

1588+
procedure TMainForm.WMPowerBroadcast(var Msg: TMessage);
1589+
begin
1590+
// Sometimes when the computer is resumed from hibernation the tree view in
1591+
// the overview frame is destroyed and recreated by Windows. Unfortunately the
1592+
// IView instances associated with the recreated tree nodes are lost.
1593+
// Attempting to read those (now nil) IView instances was resulting in an
1594+
// access violation.
1595+
case Msg.WParam of
1596+
PBT_APMSUSPEND:
1597+
// Get ready for isolation
1598+
fMainDisplayMgr.PrepareForHibernate;
1599+
PBT_APMPOWERSTATUSCHANGE:
1600+
// Restore from hibernation: ensure the IView instances are recreeated
1601+
fMainDisplayMgr.RestoreFromHibernation;
1602+
end;
1603+
end;
1604+
15851605
end.
15861606

Diff for: Src/FrOverview.pas

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at https://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2005-2023, Peter Johnson (gravatar.com/delphidabbler).
6+
* Copyright (C) 2005-2025, Peter Johnson (gravatar.com/delphidabbler).
77
*
88
* Implements a titled frame that displays lists of snippets, arranged in
99
* different ways, and manages user interaction with the displayed items.
@@ -86,6 +86,7 @@ TTVDraw = class(TSnippetsTVDraw)
8686
@return True if node is a section header, False if not.
8787
}
8888
end;
89+
8990
var
9091
fTVDraw: TTVDraw; // Object that renders tree view nodes
9192
fNotifier: INotifier; // Notifies app of user initiated events
@@ -966,7 +967,12 @@ function TOverviewFrame.TTVDraw.IsSectionHeadNode(
966967
ViewItem: IView; // view item represented by node
967968
begin
968969
ViewItem := (Node as TViewItemTreeNode).ViewItem;
969-
Result := ViewItem.IsGrouping;
970+
// Workaround for possibility that ViewItem might be nil when restarting after
971+
// hibernation.
972+
if Assigned(ViewItem) then
973+
Result := ViewItem.IsGrouping
974+
else
975+
Result := False;
970976
end;
971977

972978
function TOverviewFrame.TTVDraw.IsUserDefinedNode(
@@ -979,8 +985,12 @@ function TOverviewFrame.TTVDraw.IsUserDefinedNode(
979985
ViewItem: IView; // view item represented by node
980986
begin
981987
ViewItem := (Node as TViewItemTreeNode).ViewItem;
982-
// TODO -cBug: Exception reported as issue #70 seems to be triggered here
983-
Result := ViewItem.IsUserDefined;
988+
// Workaround for possibility that ViewItem might be nil when restarting after
989+
// hibernation.
990+
if Assigned(ViewItem) then
991+
Result := ViewItem.IsUserDefined
992+
else
993+
Result := False;
984994
end;
985995

986996
end.

Diff for: Src/Help/HTML/license.htm

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
55
* obtain one at https://mozilla.org/MPL/2.0/
66
*
7-
* Copyright (C) 2012-2024, Peter Johnson (gravatar.com/delphidabbler).
7+
* Copyright (C) 2012-2025, Peter Johnson (gravatar.com/delphidabbler).
88
*
99
* Help topic containing summary of CodeSnip license.
1010
-->
@@ -27,7 +27,7 @@ <h1>
2727
<a name="license"></a>Summary of End User License Agreement
2828
</h1>
2929
<p>
30-
DelphiDabbler <em>CodeSnip</em> is copyright &copy; 2005-2024 by Peter D
30+
DelphiDabbler <em>CodeSnip</em> is copyright &copy; 2005-2025 by Peter D
3131
Johnson, <a
3232
href="https://gravatar.com/delphidabbler"
3333
class="weblink"

Diff for: Src/Install/Assets/License.rtf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deftab709{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}}
22
{\colortbl ;\red0\green0\blue255;}
33
{\*\generator Riched20 10.0.18362}\viewkind4\uc1
4-
\pard\sa113\f0\fs18\lang1033 DelphiDabbler CodeSnip is copyright \'a9 2005-2024 by Peter D Johnson, {{\field{\*\fldinst{HYPERLINK https://en.gravatar.com/delphidabbler }}{\fldrslt{https://en.gravatar.com/delphidabbler\ul0\cf0}}}}\f0\fs18 . \par
4+
\pard\sa113\f0\fs18\lang1033 DelphiDabbler CodeSnip is copyright \'a9 2005-2025 by Peter D Johnson, {{\field{\*\fldinst{HYPERLINK https://en.gravatar.com/delphidabbler }}{\fldrslt{https://en.gravatar.com/delphidabbler\ul0\cf0}}}}\f0\fs18 . \par
55
The executable version of CodeSnip is made available under the terms of the Mozilla Public License 2.0 ({{\field{\*\fldinst{HYPERLINK https://www.mozilla.org/MPL/2.0/ }}{\fldrslt{https://www.mozilla.org/MPL/2.0/\ul0\cf0}}}}\f0\fs18 ). This means you can use, copy and distribute CodeSnip as you wish.\par
66
You may also modify CodeSnip as you wish and you may distribute copies of your modified version under the terms of the Mozilla Public License. The only exception is that you may not use the CodeSnip name or branding (e.g. the program icon) in any modification you distribute unless you have the explicit permission of the copyright holder. \par
77
For full information see the file \i License.html\i0 installed with this program.\fs24\lang2057\par

Diff for: Src/UMainDisplayMgr.pas

+30-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at https://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2005-2021, Peter Johnson (gravatar.com/delphidabbler).
6+
* Copyright (C) 2005-2025, Peter Johnson (gravatar.com/delphidabbler).
77
*
88
* Class that manages and co-ordinates the display of the program's main UI.
99
* Calls into subsidiary manager objects to perform display operations.
@@ -291,6 +291,23 @@ TMainDisplayMgr = class(TObject)
291291

292292
/// <summary>Prepares display ready for database to be reloaded.</summary>
293293
procedure PrepareForDBReload;
294+
295+
/// <summary>Gets the overview frame prepared for program hibernation.
296+
/// </summary>
297+
/// <remarks>Saves the overview tree view state ready for restoring after
298+
/// hibernation.</remarks>
299+
procedure PrepareForHibernate;
300+
301+
/// <summary>Restores the overview's tree view to have the correct IView
302+
/// instances after hibernation restores the previously saved state.
303+
/// </summary>
304+
/// <remarks>Sometimes, Windows quietly recreates the node of the tree view
305+
/// after resuming from hibernation, without restoring the associated IView
306+
/// instances, leading to access violations. This method should be called
307+
/// after resuming from hibernation to recreate the tree view with the
308+
/// correct IView instances.</remarks>
309+
procedure RestoreFromHibernation;
310+
294311
end;
295312

296313

@@ -566,6 +583,12 @@ procedure TMainDisplayMgr.PrepareForDBViewChange(View: IView);
566583
fPendingViewChange := True;
567584
end;
568585

586+
procedure TMainDisplayMgr.PrepareForHibernate;
587+
begin
588+
// simply save the state of the overview tree view ready for later restoration
589+
(fOverviewMgr as IOverviewDisplayMgr).SaveTreeState;
590+
end;
591+
569592
procedure TMainDisplayMgr.RedisplayOverview;
570593
begin
571594
(fOverviewMgr as IOverviewDisplayMgr).Display(Query.Selection, True);
@@ -593,6 +616,12 @@ procedure TMainDisplayMgr.ReStart;
593616
(fOverviewMgr as IOverviewDisplayMgr).Display(Query.Selection, True);
594617
end;
595618

619+
procedure TMainDisplayMgr.RestoreFromHibernation;
620+
begin
621+
(fOverviewMgr as IOverviewDisplayMgr).Display(Query.Selection, True);
622+
(fOverviewMgr as IOverviewDisplayMgr).RestoreTreeState;
623+
end;
624+
596625
procedure TMainDisplayMgr.SelectAll;
597626
begin
598627
// Only details pane supports text selection

Diff for: Src/VersionInfo.vi-inc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# CodeSnip Version Information Macros for Including in .vi files
22

33
# Version & build numbers
4-
version=4.24.0
5-
build=272
4+
version=4.24.1
5+
build=273
66

77
# String file information
88
copyright=Copyright © P.D.Johnson, 2005-<YEAR>.

0 commit comments

Comments
 (0)