-
1. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 20, 2010 1:43 AM (in response to starnight1981)when I add those code to anywhere in my project.
#include <boost/serialization/access.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
std::ifstream ifs("d:\\haha");
boost::archive::binary_iarchive ia(ifs);when debug, VC debug output windows shows:
"Illustrator.exe ": Loaded" C: \ Program Files (x86) \ Adobe \ Adobe Illustrator CS4 \ Plug-ins \ fp.aip ", loaded symbols.
Illustrator.exe the 0x75a0b727 of the most likely exception: Microsoft C + + exception: the memory location 0x0018f404 at std:: bad_alloc.
fp.aip is build by my project.
-
2. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 20, 2010 1:43 AM (in response to starnight1981)My illustrator is CS4
-
3. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 20, 2010 1:47 AM (in response to starnight1981)when I add those code to anywhere in my project.
#include <boost/serialization/access.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
std::ifstream ifs("d:\\haha");
boost::archive::binary_iarchive ia(ifs);when debug, VC debug output windows shows:
"Illustrator.exe ": Loaded" C: \ Program Files (x86) \ Adobe \ Adobe Illustrator CS4 \ Plug-ins \ fp.aip ", loaded symbols.
Illustrator.exe the 0x75a0b727 of the most likely exception: Microsoft C + + exception: the memory location 0x0018f404 at std:: bad_alloc.
"Illustrator.exe": uninstalled "C: \ Program Files (x86) \ Adobe \ Adobe Illustrator CS4 \ Plug-ins \ fp.aip "
fp.aip is build by my project.
Is it a bug of boost or illustrator?
-
4. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
rkansal Oct 21, 2010 6:38 AM (in response to starnight1981)Hi,
I would like to help you, but I need some more info like:
1. What is the exact place where you placed this code? I want to understand the timing of this execution.
2. Did you try catching the exceptions? You could place this piece of code inside a try-catch and see if boost/std throws an exception due to some FS error or otherwise.
--
Ruchin
-
5. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
A. Patterson Oct 21, 2010 7:27 AM (in response to rkansal)Be careful about static global variables. We've had trouble in the past with them for some reason, I can't remember exactly why. Try declaring them inside your entry point and see if you still have trouble.
-
6. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
A. Patterson Oct 21, 2010 7:28 AM (in response to A. Patterson)I should qualify that -- globals are fine for the most part. But if it doesn't load and you've got a global variable that's a fairly complex object, I'd try deferring creation. Global strings, integers, that kind of thing are fine.
-
7. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
rkansal Oct 21, 2010 8:07 AM (in response to A. Patterson)The problem with global and static objects is their lifetime.
They are constructed before the app starts execting, therefore if a global or static object allocates a memory using new, this memory is not managed by AI, which creates a problem.
Using static and global objects are fine as long as they dont use free store.
-
8. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 21, 2010 8:49 AM (in response to rkansal)Hi,
I would like to help you, but I need some more info like:
1. What is the exact place where you placed this code? I want to understand the timing of this execution.
2. Did you try catching the exceptions? You could place this piece of code inside a try-catch and see if boost/std throws an exception due to some FS error or otherwise.
--
Ruchin
This code can be written in any place, When the debugger, breakpoint simply did not enter the plug-in.
The problem with global and static objects is their lifetime.
They are constructed before the app starts execting, therefore if a global or static object allocates a memory using new, this memory is not managed by AI, which creates a problem.
Using static and global objects are fine as long as they dont use free store.
I think they caused the memory allocation, but I do not know how to solve.
boost::archive::binary_iarchive ia(ifs);
-
9. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
rkansal Oct 21, 2010 9:41 AM (in response to starnight1981)As I aksed before:
1. Could you please let me know the exact place where you placed this code? like static/global or local to a function and which function (before startup/post startup etc)?
2. If it is inside a function, did you try to place this code inside try/catch and see if any exception is raised?
3. Are you using cpp framework for the plugin?
-
10. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 21, 2010 10:17 AM (in response to rkansal)As I aksed before:
1. Could you please let me know the exact place where you placed this code? like static/global or local to a function and which function (before startup/post startup etc)?
2. If it is inside a function, did you try to place this code inside try/catch and see if any exception is raised?
3. Are you using cpp framework for the plugin?
I can give you a example:
You can insert these code into :
Adobe Illustrator CS4 SDK \ samplecode\ ADMNonModalDialog\ Source\ ADMNonModalDialog.cpp
#include "IllustratorSDK.h"
#include "ADMNonModalDialog.h"
#include "ADMNonModalDialogSuites.h"
#include "ADMNonModalDialogPlugin.h"#include <boost/serialization/access.hpp>
#include <boost/archive/binary_iarchive.hpp>#include <boost/archive/binary_oarchive.hpp>
ADMNonModalDialog::ADMNonModalDialog(SPPluginRef pluginRef) : BaseADMDialog()
{
fAccessRef = NULL;
int options = 0;// Create the Non-modal dialog. This does not necessarily show the dialog on
// the screen. If the dialog was hidden at last shutdown, it will not be shown
// until sADMDialog->Show() is called.
// Note: the init proc - Init, will be called immediately following Create()
this->Create(pluginRef, "ADMNonModalDialog", kADMNonModalDialogID, kADMTabbedFloatingDialogStyle, options);std::ifstream ifs("d:\\haha");
boost::archive::binary_iarchive ia(ifs);
}now ,build project ADMNonModalDialog.
you will found ,AI can't load ADMNonModalDialog.aip
-
11. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 27, 2010 7:01 PM (in response to starnight1981)Oh,god,help me
-
12. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
rkansal Oct 28, 2010 3:01 AM (in response to starnight1981)Did you try putting the code in try/catch and see if any exceptions are raised?
-
13. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 28, 2010 6:21 AM (in response to rkansal)Did you try putting the code in try/catch and see if any exceptions are raised?
Yes,it is also raised.
The program has not run to this code.
-
14. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
rkansal Oct 28, 2010 7:05 AM (in response to starnight1981)Could you please send your code after using try/catch.
I would rather suggest to have an assert in the catch block and see if the assertion fails.
I checked your code in CS5 and it worked.
-
15. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 28, 2010 7:30 AM (in response to rkansal)My code is same as this:
You can insert these code into :
Adobe Illustrator CS4 SDK \ samplecode\ ADMNonModalDialog\ Source\ ADMNonModalDialog.cpp
#include "IllustratorSDK.h"
#include "ADMNonModalDialog.h"
#include "ADMNonModalDialogSuites.h"
#include "ADMNonModalDialogPlugin.h"#include <boost/serialization/access.hpp>
#include <boost/archive/binary_iarchive.hpp>#include <boost/archive/binary_oarchive.hpp>
ADMNonModalDialog::ADMNonModalDialog(SPPluginRef pluginRef) : BaseADMDialog()
{
fAccessRef = NULL;
int options = 0;// Create the Non-modal dialog. This does not necessarily show the dialog on
// the screen. If the dialog was hidden at last shutdown, it will not be shown
// until sADMDialog->Show() is called.
// Note: the init proc - Init, will be called immediately following Create()
this->Create(pluginRef, "ADMNonModalDialog", kADMNonModalDialogID, kADMTabbedFloatingDialogStyle, options);std::ifstream ifs("d:\\haha");
boost::archive::binary_iarchive ia(ifs);
}now ,build project ADMNonModalDialog.
you will found ,AI can't load ADMNonModalDialog.aip
-
16. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 28, 2010 7:49 AM (in response to starnight1981)HI,rkansal :
My problem is also happened in CS5. My boost vesion is 1.44. AI plugin project is link to libboost_serialization-vc90-mt-sgd-1_44.lib
My MSN is lyj2871@163.com . Can I use MSN communicate with you?
-
17. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
rkansal Oct 28, 2010 8:06 AM (in response to starnight1981)As I said before, could you please try replacing these two lines:
h2. std::ifstream ifs("d:\\haha");
boost::archive::binary_iarchive ia(ifs);
with
try{
h2. std::ifstream ifs("d:\\haha");
boost::archive::binary_iarchive ia(ifs);
}catch(...)
{
assert(false && "Exception in boost::archive::binary_iarchive");
}and see of the assertion fails?
-
18. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 28, 2010 8:13 AM (in response to rkansal)what is h2.std ???
h2??????
-
19. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 28, 2010 8:16 AM (in response to rkansal)I have used try...catch .
-
20. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
rkansal Oct 28, 2010 8:46 AM (in response to starnight1981)ignore h2, that was just typo
Did you get the assertion failure in catch statement?
-
21. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 28, 2010 9:08 AM (in response to rkansal)Did you get the assertion failure in catch statement?
no,the program is not run to this try....catch.....
-
22. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Oct 28, 2010 9:16 AM (in response to rkansal)Hi,rkansal ,Can I use MSN communicate with you? I want to give you some screenshots.
-
23. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
rkansal Oct 28, 2010 11:00 AM (in response to starnight1981)Can you use yahoo? I am online at ruchin.kansal@yahoo.com.
-
24. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
rkansal Nov 2, 2010 11:06 AM (in response to starnight1981)Hi,
I looked at your code and tried to debug your problem.
The problem is happenning because boost's serialization creates a static singleton instance. The static members are initialized at the time of dll attach, so before calling any function of the plugin, boost tries to allocate memory for the static instance.
You have included ASMemory.cpp which overrides the new operator, therefore this new operator is called at the time of static member construction.
However new fails to allocate memory since spBlock suite is not acquired by the plugin yet!
I hope it helped you in understanding the cause of the failure.
Having said that, I will suggest try the following solutions:
1. Simplest one is to remove the ASMemory.cpp from your project so that default CRT new is called instead.But, it has a risk. If you pass memory pointer to some other AI API which tries to deallocate it, you are going to be in trouble. So, watch it!
2. Try to build a dynamic linked version of boost lib so that you dont have to link statically against it. That way, AI will not interfere with the memory management of boost, but it also has a risk. If you pass a pointer of some object to boost and for some reason, it keeps and tries to destroy it later, it might be a problem. This possiblity could be eliminated by checking the function documentation which you are going to use from the boost library.
Try to see which one suits you, and let me know if you have any more questions/doubts.
I hope it helped!
-
25. Re: Is It can not use boost::archive::binary_iarchive in develop ai plugin?
starnight1981 Nov 5, 2010 9:19 AM (in response to rkansal)Thank you very much!
I tried the first method, but when the illustrator is closed, the program crashes and error prompts appear.
I think the second method is not suitable for me, because I do not want to use the other dll
So, I think I do not use the boost serialization library


