|
|
Home » Community » Coffee corner » [SOLVED]Sharing Ptr of object to dll
[SOLVED]Sharing Ptr of object to dll [message #52172] |
Thu, 01 August 2019 15:09 |
|
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
Hello community,
I have a programm wich load a dll. This dll carry class wich have a public attribut "object* object;"
this public attribut is fill by my main programm like that: ptrToTheClass->object = myMainObjectPtr;
then when I use method of my dll wich use the objectDll ptr it crash.
However my objectDll Ptr have the right address of the main object so I dont get why it crash.
(I have checked by using log and the problem occur when I call method of ptrToTheClass->object)
Someone have an idea ? maybe I can't share object between my Dll instance of object and my programm ?
here I show you :
Method of my dll:
void Discord_Minecraft::launchCommande(ValueMap payload){
ptrBot->CreateMessage(ChannelLastMessage, "SmartUppBot DLL hot LOAD !"); //the crash occur here (the ptrBot addr is right)
}
here is creation of Discord_Minecraft object and filling of ptrBot :
DiscordModule* test = facto(); //Test is my Discord_Minecraft DLL object
test->ptrBot = getBotPtr(); // here I fill ptrBot
Thanks in advance.
Best Regard.
[Updated on: Wed, 07 August 2019 09:53] Report message to a moderator
|
|
|
|
Re: Sharing Ptr of object to dll [message #52178 is a reply to message #52175] |
Fri, 02 August 2019 13:19 |
|
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
mirek wrote on Fri, 02 August 2019 09:02Xemuth wrote on Thu, 01 August 2019 15:09
Someone have an idea ? maybe I can't share object between my Dll instance of object and my programm ?
Literally a lot of things can go wrong here. For starters, try to "USEMALLOC". Anyway, in general, sharing should work.
Mirek
Hello Mirek, I have try and it change nothing but I have digging deeply my code and the crash occure when, in the dll I want do this kind of thing :
req.New(); //req is HttpRequest Object, When I'm in debug mode, the crash occure here
Json json("content", message);
req.Url(baseUrl); // When I'm in release the crash occure here
req.Path("/api/channels/" + channel + "/messages");
req.POST();
req.Post(json);
String response =req.Execute();
LOG(response);
ValueMap m = ParseJSON(response);
ApplyRateLimits(req);
LOG(req.GetContent());
Seems like I have trouble to use HttpRequest within DLl even if Core and Core/SSL are built in.
May Request/Socket work differently when built in Dll ?
|
|
|
|
|
|
Re: Sharing Ptr of object to dll [message #52188 is a reply to message #52187] |
Tue, 06 August 2019 22:29 |
Novo
Messages: 1371 Registered: December 2006
|
Ultimate Contributor |
|
|
Do not forget that your DLL is containing another copy of U++. That includes memory allocator. And this means that if you somehow allocated memory in your DLL, then you should free it inside of this DLL. The same is related to your app.
Have fun!
Regards,
Novo
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 17:50:08 CEST 2024
Total time taken to generate the page: 0.02475 seconds
|
|
|