|
From: <dav...@us...> - 2009-08-14 08:30:30
|
Revision: 824
http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=824&view=rev
Author: davidvtaylor
Date: 2009-08-14 08:30:21 +0000 (Fri, 14 Aug 2009)
Log Message:
-----------
Fix for "ModelExplorer can cannot insert InstantRegisterClasses on an "empty" unit" under D2009
- Added logic to explicitly set the StartPos and EndPos of the newly added InitializationSection.
Note: The design of the original logic is flawed and fails to properly initialize the position of newly inserted Code Sections. The code worked under previous versions of Delphi, but apparently largely by accident. A related coding error in TInstantCodeModifier.InsertObjectText corrected in Rev 815 appears to have masked this defect.
Revision Links:
--------------
http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=815&view=rev
Modified Paths:
--------------
trunk/Source/Core/InstantCode.pas
Modified: trunk/Source/Core/InstantCode.pas
===================================================================
--- trunk/Source/Core/InstantCode.pas 2009-08-14 07:22:59 UTC (rev 823)
+++ trunk/Source/Core/InstantCode.pas 2009-08-14 08:30:21 UTC (rev 824)
@@ -25,7 +25,7 @@
*
* Contributor(s):
* Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Steven Mitchell,
- * Uberto Barbini, Joao Morais, Riceball Lee, Brian Andersen
+ * Uberto Barbini, Joao Morais, Riceball Lee, Brian Andersen, David Taylor
*
* ***** END LICENSE BLOCK ***** *)
@@ -8880,15 +8880,22 @@
var
Section: TInstantCodeInitializationSection;
+ Origin: TInstantCodePos;
Pos: TInstantCodePos;
begin
Section := Module.InitializationSection;
if not Section.IsFiled then
begin
CursorPos := Module.ImplementationSection.EndPos;
+ Origin := CursorPos;
InsertMode := imAfter;
InsertObjectText(Section);
+
+ // Set position of newly added Initialization section
+ Section.StartPos := Origin;
+ Section.EndPos := CursorPos;
end;
+
CursorPos := Section.StartPos;
SkipLine;
if FindText(RegisterProcName) then
|