-
1. Re: Null pointer exception in cs3&4 but not in cs5 / Get Plugin folder/path
Another Andrew Jun 27, 2010 4:50 PM (in response to nope0000)First off, a dumb question: are you using this code in a thread?
CS5 is very picky about not liking InDesign framework calls in a thread.
You could try a Win native code for creating this path and see if that crashes.
--
Alternatively we could approach the code completely differently.
You said you tried a few ways, but how about something like:
IDFile aFile;
FileUtils::GetAppFolder(&aFile);
FileUtils::AppendPath(&aFile, "Plug-ins");
FileUtils::AppendPath(&aFile, "myPlugin.pln");
PMString thePath = aFile.GetString();
??
-
2. Re: Null pointer exception in cs3&4 but not in cs5 / Get Plugin folder/path
RorohikoKris-13MMcy Jun 27, 2010 10:51 PM (in response to nope0000)This does not address the reason why things crash, but it does address your main goal: getting the path of your plug-in.
AFAIK, you'd be better to consult IID_IPLUGINLIST on the session boss. That gives you access to the path to your plug-in.
In the incomplete, untested sample below, kMyPluginID stands for your plugin's ID (see your ...ID.h file).
do {
...
ISession* session = GetExecutionContextSession();
InterfacePtr<IPlugInList> pluginList(session, IID_IPLUGINLIST);
if (pluginList == NULL)
break ;
IDFile path;
if (! pluginList->GetPathName(kMyPluginID, &path))
break;
...}while (false);Something like that (waves hands)...HTH!Cheers,Kris -
3. Re: Null pointer exception in cs3&4 but not in cs5 / Get Plugin folder/path
nope0000 Jun 28, 2010 10:20 AM (in response to RorohikoKris-13MMcy)Thank you for your answers
I tried both, the results are the same as with the other ways i already tried, exception after function return.
In CS5 where all thre examples are working the plugin is compiled with different switches. I tried those without success. If i continue program execution in the debug session the code is working in cs3 and 4.
Any suggestions?
-
4. Re: Null pointer exception in cs3&4 but not in cs5 / Get Plugin folder/path
RorohikoKris-13MMcy Jun 28, 2010 1:31 PM (in response to nope0000)I suspect the crash is a symptom of something deeper and/or earlier - some interface pointer that got released prematurely/too often, some memory that got overwritten. Those kinds of things tend to result in 'delayed crashes' in seemingly unrelated areas of the code - it all depends what got overwritten or what area got affected by the extra Release() call.
Make sure you're using the debug version.
Double-check your InterfacePtr<...> management (do a global source-code search for creations of them throughout your code and visually verify ALL of them. GREP is your friend) and make sure they're all the correct type (1-param vs. 2- or 3-param version: rule of thumb: the former needs to be used with Query... or Create... calls, the latter with Get... calls).
Double-check your memory allocations; look for signs of overrun.
Study the crash closer (look at the stack crawl).
Switch platforms (Mac to Win or vice versa).
...
Cheers,
Kris
-
5. Re: Null pointer exception in cs3&4 but not in cs5 / Get Plugin folder/path
Yuqi Peng Jun 29, 2010 10:01 AM (in response to nope0000)I would suggest you to use
PluginID plugInID=GetPlugIn()->GetPluginID();
to get your PlugIN ID
InterfacePtr<IPlugInList>listOfPlugin(mgSession,IID_IPLUGINLIST);
if (listOfPlugin==nil) {
break;
}
//
bool16 pOK=listOfPlugin->GetPathName(plugInID,&idFileName);
if (pOK==kFalse) {
break;
}
then try the same code. I use similar method in CS5, CS4, it never failed.
-
6. Re: Null pointer exception in cs3&4 but not in cs5 / Get Plugin folder/path
nope0000 Jun 29, 2010 11:02 PM (in response to Yuqi Peng)I already tried that since it is the same as Kris sugested.
I agree that ipluginlist is the better way to to achieve what i
am triing to, but it fails. I think the reason is that i convert the path which is
PMString to std::string.
However what i found is that the first code (and the two suggested too) is working with cs3,4,5 on window XP but fails with cs3,4 on windows 7, no mather if compiled on win7 or xp.
There is again another new thread about an Indesign failing with C0000005...
Is there another way to convert PMString to std::string than the suggested GetPlatformString()?
-
7. Re: Null pointer exception in cs3&4 but not in cs5 / Get Plugin folder/path
nope0000 Jul 4, 2010 11:21 AM (in response to nope0000)I made a workaround using native win
32 api code instead of Indesign SDK to get the plugin folder.
This workaround runs with CS3/4 on Windows 7.
As soon as i ported the plugin to Mac i am going to test the code on OSx also.
-
8. Re: Null pointer exception in cs3&4 but not in cs5 / Get Plugin folder/path
MatsT Jul 8, 2010 4:55 AM (in response to nope0000)The reference returned by GetPlatformString will still reference the same memory as the PMString, and when the PMString goes out of scope you will get this error if you try to use the string. You need to use GetPlatformString().c_str() and the problem should fix itself.
And as other people have mentioned it's better to stick to IDFile for as long as possible when handling paths to make InDesign handle platform specifics.

