Function member of my own implementation not called

Community Beginner ,
Jan 07, 2021 Jan 07, 2021

Copy link to clipboard

Copied

Hi,
I have a problem with a member function of my own implementation that is not called inside a member function of an utils object.

 

Model plugin :
MyData interface :

class IMyData : public IPMUnknown
{
public:
   enum { kDefaultIID = IID_IMYDATA };
   virtual void myTest() = 0;
};

MyData implementation :

class MyData : public CPMUnknown<IMyData>
{
public:
   MyData(IPMUnknown* boss) : CPMUnknown<IMyData>(boss) {}
   virtual ~MyData() {}
   virtual void myTest();
};

CREATE_PMINTERFACE(MyData, kMyDataImpl)

void MyData::myTest()
{
   std::ofstream file;
   file.open("E:/myTest.log");
   file << "myTest";
   file.flush();
   file.close();
}

TestUtils interface :

class ITestUtils : public IPMUnknown
{
public:
   enum { kDefaultIID = IID_ITESTUTILS };
   virtual void startTest() = 0;
};

TestUtils implementation :

class TestUtils : public CPMUnknown<ITestUtils>
{
public:
   TestUtils(IPMUnknown* boss) : CPMUnknown<ITestUtils>(boss) {}
   virtual ~TestUtils() {}
   virtual void startTest();
};

CREATE_PMINTERFACE(TestUtils, kTestUtilsImpl)

void TestUtils::startTest()
{
   std::ofstream file;
   file.open("E:/startTest.log");
   file << "startTest";
   file.flush();
   file.close();

   InterfacePtr<IMyData> foobar(::CreateObject2<IMyData>(kFooBarBoss));
   foobar->myTest();
}

.fr in ClassDescriptionTable:

Class
{
   kFooBarBoss,
   kInvalidClass,
   {
      IID_IMYDATA, kMyDataImpl,
   }
}

 

UI plugin :
I have a PanelController with a Process function triggered when I push a button (thanks to a PanelObserver) :

void PanelController::Process()
{
   Utils<ITestUtils>()->startTest();
}

 

My problem : when I click on the button of my UI plugin, a file E:/startTest.log is created with startTest inside but I don't have the E:/myTest.log file.
The startTest() member function of TestUtils is called but not the myTest() of the foobar object. What did I do wrong ?
Thanks for your answers.

TOPICS
SDK

Views

99

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 07, 2021 Jan 07, 2021

Copy link to clipboard

Copied

You don't mention a crash in that call to foobar->myTest() . So I assume the impl is registered correctly, ends up in factory and you actually call the function but it just does not work as intended.

Set a breakpoint on that line in startTest() and step in - maybe your function is called and there's something wrong with the file. Directory "E:" readonly?

Also, get a hold on the debug build. Apply to *developer* prerelease.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

No crash, the E:/myTest.log file is just not created.
It's weird because the E:/startTest.log IS created and it's exactly the same thing so it's not a readonly access problem.
Yeah I know it's much simpler with a debug build but I don't have one because I don't apply to the InDesign Developers Prerelease program, and I don't know if I have the right to. As I understand, it's subject to approval by an Adobe team so...

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

Ok so I applied to the developers prerelease program and I have now access to the debug build. After launching the debug version I had a lot of "Implementation registered twice" errors because I set my PrefixNumber for both model and UI plugins with consecutive numbers (0xd9101 and 0xd9102). After I fixed this, the problem was solved !

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines