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++ Widgets - General questions or Mixed problems » QTF with QtfRichObject as Button label causes crash
Re: QTF with QtfRichObject as Button label causes crash [message #26458 is a reply to message #26438] Tue, 04 May 2010 17:35 Go to previous message
mirek is currently offline  mirek
Messages: 13976
Registered: November 2005
Ultimate Member
It is because QtfRichObject is only temporary reference to the RichObject.

You are using this reference, but then parsing qtf on Button paint, when RichObject does not exist anymore.

One possible solution:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

GUI_APP_MAIN
{
	Button button;
	
	{
		DrawingDraw dd(63, 187);
		dd.DrawImage(0,0,CtrlImg::exclamation());
	
		static Size ppi(72,72);// = ScreenDraw(true).GetPixelsPerInch();
		QtfRichObject qrdd(CreateDrawingObject(dd.GetResult(), Size(63*ppi.cx/10, 187*ppi.cy/10), Size(63*ppi.cx/10, 187*ppi.cy/10)));
	
		String qtf;
		qtf << qrdd;
		
		button.SetLabel("\1" + AsQTF(ParseQTF(qtf)));
	}
	TopWindow win;
	win.Add(button.SizePos());
	win.Run();
}


Note: I agree the situation is a little bit tricky, some widgets parse QTF on set (like RichTextView) - this would be no problem for these. Others parse QTF during Paint. Generally, everywhere where QTF needs '\1' prefix, it is being parsed during Paint.
 
Read Message
Read Message
Previous Topic: WhenSelected callback to DropList
Next Topic: Proposal: add IsReadOnly() handling inside ButtonOption
Goto Forum:
  


Current Time: Fri May 10 18:12:34 CEST 2024

Total time taken to generate the page: 0.02863 seconds