Restoring table header from a string


#1

Hello
I have a TableHeaderComponent which is serialized to a file as this string:

Below code checks if the table.dat exists, if it exists it restores the header, if it does not exist it loads the default setttings. But in actual, it does not show the header columns altough it finds and reads the table.dat file.
Do i miss something?

	juce::String path = File::getCurrentWorkingDirectory().getParentDirectory().getFullPathName();
	path += "\\table.dat";
	juce::File f(path);
	if (f.existsAsFile())
	{
		TableHeaderComponent& headerComponent = table_.getHeader ();
		juce::FileInputStream fis(f);
		juce::String tableStr = fis.readString();
		headerComponent.restoreFromString(tableStr);
		headerComponent.repaint();
		headerComponent.resized();
		table_.setHeader(&headerComponent);
	}
	else
	{
		AddDefaultColumns ();
		table_.getHeader ().setSortColumnId (TradeTableColumn::Column::COLUMN_ID, false);
	}

#2

Looks vaguely ok, you need to get in there with your debugger and it’ll probably be obvious what’s happening!

Important note: NEVER manually concatenate filenames with slashes like that! Always use File::getChildFile() to avoid nasty slip-ups and platform specifics!