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++ Callbacks and Timers » manually creating callback
manually creating callback [message #41865] Sat, 01 February 2014 03:30 Go to next message
piotr5 is currently offline  piotr5
Messages: 103
Registered: November 2005
Experienced Member
I get Invalid memory access! with the following code (with and without MT flag):

#include <Core/Core.h>

CoWork cw;

struct delme : public CallbackAction{
	virtual void Execute() {}
};

CONSOLE_APP_MAIN
{
	delme d;
	cw.Do(Callback(&d));
	cw.Finish();
}


how does this differ from the callbacks created by the actual generator functions? for example if I instead write
cw.Do(callback(&d,&delme::Execute))
it works fine.

[Updated on: Sat, 01 February 2014 05:12]

Report message to a moderator

Re: manually creating callback [message #42013 is a reply to message #41865] Mon, 10 February 2014 20:24 Go to previous message
mirek is currently offline  mirek
Messages: 12616
Registered: November 2005
Ultimate Member
It has to be allocated on heap

#include <Core/Core.h>

using namespace Upp;

CoWork cw;

struct delme : public CallbackAction{
	virtual void Execute() {}
};

CONSOLE_APP_MAIN
{
	cw.Do(Callback(new delme));
	cw.Finish();
}


(not very U++-ish, but then you are not supposed to do this Smile

[Updated on: Mon, 10 February 2014 20:24]

Report message to a moderator

Previous Topic: Callback to refresh docked window
Next Topic: Feature request
Goto Forum:
  


Current Time: Wed Aug 12 00:46:53 CEST 2020

Total time taken to generate the page: 0.03020 seconds