1
Programming / Re: Environment goes away when dropping a file on a WPProgram object
« on: June 05, 2025, 08:10:17 am »
Rich,
Thanks for that explanation. I knew that wpOpen() in the program object wasn't getting called when a file was dropped, but I didn't know what was getting called and how the program was executed . Is wpOpen() called in the datafile object when it is double-clicked and it then runs the program by querying PROGDETAILS the same way?
I am afraid that I probably am causing the problem because I am overriding wpQueryProgDetails() in the program object and modifying the contents of PROGDETAILS - which it appears that DTProgram is picking up on a drag/drop and hence the issue.
I could add the "standard" environment to PROGDETAILS since I am modifying some of the contents anyway. And that may be the best solution. But I am a little worried about a memory overrun. Most of the time when wpQueryProgDetails() is called it is called twice: the first time with a NULL pointer for returning the contents of the PROGDETAILS in order to get the needed size for allocating the memory to hold the PROGDETAILS and the second time with a pointer to the memory allocated to hold the PROGDETAILS with the pointer hopefully the correct size. But I have noticed that sometimes it is only called once, with an "assumed large enough" size allocated for holding PROGDETAILS, (If I am remembering correctly the size I saw was 1024) If I add in the standard environment it could exceed that "assumed large enough" size.
I saw that "only call once with an assumed large enough size" behavior on a machine that was running eWorkplace, but I don't know if that is a eWorkplace particular behavior or something else that was installed on that machine that was calling wpQueryProgDetails().
Thanks for the help.
Quote
When you drop a datafile on a program object, the pgm object does *not* open the file. Instead, the datafiles's wpDroppedOnObject() method is called, advising that it was just dropped on the pgm object. The datafile then queries the pgm object for its PROGDETAILS structure which contains the particulars for that program. Using this info, the datafile runs the program itself. And here lies the problem...
Thanks for that explanation. I knew that wpOpen() in the program object wasn't getting called when a file was dropped, but I didn't know what was getting called and how the program was executed . Is wpOpen() called in the datafile object when it is double-clicked and it then runs the program by querying PROGDETAILS the same way?
I am afraid that I probably am causing the problem because I am overriding wpQueryProgDetails() in the program object and modifying the contents of PROGDETAILS - which it appears that DTProgram is picking up on a drag/drop and hence the issue.
I could add the "standard" environment to PROGDETAILS since I am modifying some of the contents anyway. And that may be the best solution. But I am a little worried about a memory overrun. Most of the time when wpQueryProgDetails() is called it is called twice: the first time with a NULL pointer for returning the contents of the PROGDETAILS in order to get the needed size for allocating the memory to hold the PROGDETAILS and the second time with a pointer to the memory allocated to hold the PROGDETAILS with the pointer hopefully the correct size. But I have noticed that sometimes it is only called once, with an "assumed large enough" size allocated for holding PROGDETAILS, (If I am remembering correctly the size I saw was 1024) If I add in the standard environment it could exceed that "assumed large enough" size.
I saw that "only call once with an assumed large enough size" behavior on a machine that was running eWorkplace, but I don't know if that is a eWorkplace particular behavior or something else that was installed on that machine that was calling wpQueryProgDetails().
Thanks for the help.