Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Strange Issue with with ToolsAPI in creating a IOTAProjectCreator


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
sunil arora

Posts: 13
Registered: 10/1/00
Strange Issue with with ToolsAPI in creating a IOTAProjectCreator  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2014 4:40 AM
I was trying to create a project creator wizard, when I came across a strange issue. May be I am doing something silly but am not able to spot it, so would request you to have a look at it & advise if you can spot or guess the reason of failure.

I have created created a repository wizard along with IOTAprojectCreator & IOTA file & have registered the same. The purpose of the repository wizard is to register my ProjectCreator wizard into the the Delphi project repository which comes up when user clicks on menu
"File"-->"New"-->"Other" so that a pre-configured & customized project could be presented to the developer from where they can take on. The actual work gets done in a method "Execute" for the ProjectCreator which inturns creates a new Module

This all works well if there is already some project opened & user tries to add new project to existing group. My new project gets created/added to the existing ProjectGroup

The event chain is always a call from "Execute" --> "(BorlandIDEServices As IOTAModuleServices).CreateModule" --> inheritd methods named "GetOwner" to "GetFileName"

But if there is no active project then it goes weird! When a call is made to "GetFileName" then the IDE prompts to Save (presumably closing current & trying to open new) ProjectGroup (which is not active in any case??) If I Save that group, it just creates a new Project group with no listed project (but debugger showing the increased ModuleCount for the group)... If I cancel the save operation then it sometime keep silent sometimes giving an AV .... Looks like somehow
a) It marks the current/default ProjectGroup as Modified & for my Project it tries to creates a new ProjectGroup thereby asking for save
b) If I do not save then next dependency gets broken & so the AV
c) If I do save it, it goes on to create a new projectGroup & my Project (presumably based on the increased module count) under it but somehow not able to activate & make that project visible

Now, I have tried tried all the different option for GetFileName & GetOwner (that is where I suspect the issue is :( )
For filename, I have tried hardcoded fileName, defaultFileName from IDE, as well as empty string . For Owner I have tried MainProjectGroup, getActiveProject as well as NIL

But none of these combination seem to help; as per my previous understanding & all the material on the web, the NIL as an owner should always be accepted by IDE to return a new projectgroup with the new project

The stack trace from Delphi 2007 (is almost same from XE7, XE5, XE3, XE, 2010, 2009 for which I have tried this so far) is as below:

****
rtl100.bpl } System.ErrorAt (Line 3291, "sys\system.pas" + 3) + $4
[209CE214]{coreide100.bpl} ProjectGroup.TProjectGroup.GetProjectContainer (Line 1088, "ProjectGroup.pas" + 1) + $A
[209E2ADE]{coreide100.bpl} ProjectModule.TBaseProject.AddToViewers (Line 629, "ProjectModule.pas" + 4) + $F
[209E7DBE]{coreide100.bpl} ProjectModule.TCustomCodeIProject.AddToProjectGroup (Line 2501, "ProjectModule.pas" + 6) + $4
[20A2ED89]{coreide100.bpl} IDEServices.TIDEServices.DoCreateProject (Line 1712, "IDEServices.pas" + 25) + $1F
[20A2FB17]{coreide100.bpl} IDEServices.TIDEServices.CreateModule (Line 1987, "IDEServices.pas" + 4) + $7
[016119AD]{PlugWiz.bpl } Uplugwizard.TSKAPlugProjectWizard.Execute + $89
****

The related code is as below:

type
TSKAPlugProjectWizard = class(TNotifierObject, IOTAWizard,
IOTARepositoryWizard, IOTAProjectWizard)
function GetIDString: string;
function GetName: string;
function GetState: TWizardState;
procedure Execute;
function GetAuthor: string;
function GetComment: string;
function GetPage: string;
function GetGlyph: Cardinal;
end;

TskaPlugProjectCreator = Class(TInterfacedObject, IOTACreator,
IOTAProjectCreator)
Private
FProjectName : String;
Protected
Public
Constructor Create(strProjectName : String);
// IOTACreator
Function GetCreatorType: String;
Function GetExisting: Boolean;
Function GetFileSystem: String;
Function GetOwner: IOTAModule;
Function GetUnnamed: Boolean;
// IOTAProjectCreator
Function GetFileName: String;
Function GetOptionFileName: String;
Function GetShowSource: Boolean;
Procedure NewDefaultModule;
Function NewOptionSource(Const ProjectName: String): IOTAFile;
Procedure NewProjectResource(Const Project: IOTAProject);
Function NewProjectSource(Const ProjectName: String): IOTAFile;

End;
**********************

procedure TSKAPlugProjectWizard.Execute;
var
Module: IOTAModule;
cr: IOTAProjectCreator;
begin
cr := TskaPlugProjectCreator.Create(FProjectName);
Module:= (BorlandIDEServices As IOTAModuleServices).CreateModule(cr);
.....
end;

function TskaPlugProjectCreator.GetFileName: String;
begin
Result := FProjectName + '.dpr'; ///Result :=Nil;
end;

function TskaPlugProjectCreator.GetFileSystem: String;
begin
Result := '';
end;

function TskaPlugProjectCreator.GetOwner: IOTAModule;
var
services: IOTAModuleServices;
begin
//services := (BorlandIDEServices as IOTAModuleServices);
//Result := services.MainProjectGroup;
Result := Nil;
end;

function TskaPlugProjectCreator.GetUnnamed: Boolean;
begin
Result := True;
end;

function TskaPlugProjectCreator.NewProjectSource(
const ProjectName: String): IOTAFile;
begin
Result := TSKAPlugProjectFile.Create(FProjectName);
end;

PLEEEEEEEEEEEEEase HELP

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02