Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Crash on LoadFromFile
Re: Crash on LoadFromFile [message #11916 is a reply to message #11914] Mon, 01 October 2007 09:07 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
Mindtraveller wrote on Sun, 30 September 2007 21:54

Proceeding with U++ usage led me to another strange moment, which I couldn`t solve with docs&forum search.
Loading config in a closest to examples manner, crashes application with assert in debug mode:

index.php?t=getfile&id=757&private=0



May be I`m doing something wrong, but I don`t see any difference between my code and docs-how-it`s-done-right:
#define CONFIG_FILE "config."

struct Config
{
	wxBaud   baud;
	wxParity parity;
	int      com;
	int      wordlen;
	int      stopbits;
	int      addr;
	
	void Serialize(Stream& s)
	{
		s.Put(&baud, sizeof(baud));
		s.Put(&parity, sizeof(parity));
		s % com % wordlen % stopbits % addr;
	}
};
Config config; 

void Kran::LoadAndInit()
{
	if (!LoadFromFile(config, ConfigFile(CONFIG_FILE)))
	{
		config.baud     = wxBAUD_38400;
		config.com      = 1;
		config.parity   = wxPARITY_NONE;
		config.wordlen  = 8;
		config.stopbits = 1;
		config.addr     = 1;
	}

This code causes assertion in LoadFromFile.

Could you please help with this?


You cannot Put (in Serialize) when LoadFromFile...

The issue is a little bit complex, but the quick fix is to use SerializeRaw instead of Put (that will provide raw binary load if loading and raw binary write if storing).

Mirek
 
Read Message
Read Message
Read Message
Previous Topic: Transfer Semantics - Initializer list and copy constructors
Next Topic: is there a function to stop the program N milliseconds?
Goto Forum:
  


Current Time: Wed Sep 03 21:30:09 CEST 2025

Total time taken to generate the page: 0.07400 seconds