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
QTF with QtfRichObject as Button label causes crash [message #26438] Sat, 01 May 2010 23:26 Go to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

	//ButtonOption button;

	DrawingDraw dd(63, 187);
	dd.DrawImage(0,0,IMG::silo_small);

	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)));

	//setup button label
	button.SetRect(x,y,116,300);
	String qtf;
	qtf << qrdd;
	
	PromptOK(qtf); // <<-- works perfectly
	
	qtf.Insert(0, '\1');
	button.SetLabel(qtf); // <<-- causes no run-time error itself, but app crashes on painting this button

I've noticed that in case of drawing Image inside Prompt-dialog, image is painted with noticable delay (about 100-200 milliseconds). May be it is somehow interconnected with painting button error...

P.S. The image is painted on white background, while it is semi-transparent itself. Is there a way to paint it using transparent background?

[Updated on: Sat, 01 May 2010 23:30]

Report message to a moderator

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: 13975
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.
Previous Topic: WhenSelected callback to DropList
Next Topic: Proposal: add IsReadOnly() handling inside ButtonOption
Goto Forum:
  


Current Time: Fri Mar 29 00:24:09 CET 2024

Total time taken to generate the page: 0.01317 seconds