Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /storage/content/49/145849/famitracker.com/public_html/forum/classes/dbHandler.php on line 29 FamiTracker
Login:
Menu:
Post: Author:
FamiTracker > General > Bug Reports & Feature Requests > Export plugin bug in 0.3.6 Owner: Shiru New post
Page 1 of 1 Sort:  
Export plugin bug in 0.3.6 Posted: 2011-05-08 04:31 Reply | Quote
Shiru



Member for: 4890 days
Location: Russia, Moscow
Status: Offline

#16987
Noticed a bug with my TextExporter plugin in 0.3.6: when you export something, it sometimes does not create file at all, although reports that export was successful. More rarely it creates file with zero size. Other times it works correctly. If I repeat the same actions to export, restarting FT between the attempts, the result could be different (no file, correct file, file with zero size).

Previously I used export in 0.3.6 and had no problems, but this was on other computer. I noticed the problem with a multisong NSF, previously I only used export with single song NSFs.

Posted: 2011-05-08 22:27 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#17019
I'm not sure if this is a bug in famitracker. The exporter plugin receives the file name as a string and then it's up to the plugin to handle the actual file operations, I think debugging the plugin is necessary here.

_______________________
Programmer and developer
Posted: 2011-05-08 23:17 Reply | Quote
Shiru



Member for: 4890 days
Location: Russia, Moscow
Status: Offline

#17021
I have no slightest idea what could possibly be wrong in a 200 lines program which is basically

std::ofstream os;

os.open(fileName);
os<< things;
os.close();

and which is actually worked previously without these problems. I also have no idea what to debug there. fileName that received from FT is always correct, that's for sure.

If you think there could not be problems on FT side, OK then.

Posted: 2011-05-08 23:33 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#17024
Actually I'm not sure if the problem is in FT but I assume not since the file is entirely created by the plugin and never touched by FT, especially if you know the file path is correct. I have the source of your plugin here so I'll take a look and see if I find anything.

_______________________
Programmer and developer
Posted: 2011-05-08 23:43  (Last Edited: 2011-05-08 23:44) Reply | Quote
Shiru



Member for: 4890 days
Location: Russia, Moscow
Status: Offline

#17025
When I worked on the plugin, using Gradualore's dev builds (he added and removed needed export features in process), I had problems with compatibility - he made changes, I didn't, and program crashed, but in this case it exported at least something, or created empty file if crashed really early.

I assume that in any case, if os.open was executed, an empty file should be created. Nothing happens before os.open, it is the first executed line of code in Export function, so I have no idea how it could work one time and not work other time (under the same circumstances, with exactly the same FTM and action sequence).

Posted: 2011-05-08 23:57 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#17026
Yeah it sounds like a case of using uninitialized memory or something. Not creating a file at all could be the plugin not getting called properly, but that wouldn't explain the empty file.

It works fine here with both single and multisong files. Are you using different OSes on the computer where it worked and where it didn't?

_______________________
Programmer and developer
Posted: 2011-05-09 00:02  (Last Edited: 2011-05-09 00:03) Reply | Quote
Shiru



Member for: 4890 days
Location: Russia, Moscow
Status: Offline

#17027
Both are Win XP, in both cases under admin rights.

I also tested it with single song files, the problem occurs with them too.

Posted: 2011-05-09 00:21  (Last Edited: 2011-05-09 00:32) Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#17029
I didn't write the plugin code in FT but I will try and see if I can find anything that might cause problems. Beside that the only thing I can think of is if you have the possibility to run the DLL in a debugger while exporting and see if it gives any clues, I think it's possible to do with visual studio.

Ok I think I found something: the file object is a global object in your plugin, this is usually not recommended in DLLs. Also, the file object is not closed when the function has finished.

_______________________
Programmer and developer
Posted: 2011-05-09 00:54  (Last Edited: 2011-05-09 01:07) Reply | Quote
Shiru



Member for: 4890 days
Location: Russia, Moscow
Status: Offline

#17036
It is closed in my WIP version, by some reason it wasn't in public one. Makes no difference for the problem (tested).

I've just made the file object non-global, nothing has changed.

Edit: or maybe changed, after some testing. I haven't seen zero-size file after these changes, and seems it now works more definitely - if I'm trying to save a file into dir with non-latin symbols, it does not work (no file, despite positive report), and if I'm trying to save it into a dir with latin characters only, it worked every time I've tested it now. Non-latin symbols is probably a different problem, related to Windows versions I'm using (maybe localization works differently), although NSF export still works with non-latin paths.

Posted: 2011-05-09 01:28  (Last Edited: 2011-05-09 01:28) Reply | Quote
Shiru



Member for: 4890 days
Location: Russia, Moscow
Status: Offline

#17040
Fixed the non-latin path problem, so far testing shows that the whole problem solved (so it was at my plugin side).

Posted: 2011-05-09 17:55 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#17072
Great! NSF exporting is using windows file functions instead of ofstream, if that could be the reason.

_______________________
Programmer and developer
Page 1 of 1 Sort: