Trying to do the Eclipse RCP tutorial and getting compile errors when doing Chapter 3 - Create your first RCP application?
Errors you might be getting:
- Type AbstractUIPlugin cannot be resolved to a type
- Bundle org.eclipse.ui cannot be resolved
- Compile errors
Try this:
1. Click on Window->Preferences
2. Expand Plug-In Development on the tree
3. Click Target Platform
4. Make sure "Running Platform" is active, if it's not, tick it, and click reload, then try to build your project again.
Tuesday, May 18, 2010
Monday, February 2, 2009
Embedding Boost Python
Just spent 6 hours trying to solve an issue with class wrapping using Boost with embedded code and pointers.
Imagine your code looks something like this where you are tying to define a global variable that will be availiable to a python program. The global variable is actually an instance pointer to a C++ class.
Now, whenever you try to run it, you get an error:
The culprit is the statement main_namespace["myInstance"] = myInstance;. Basically it's saying there is no convertor. Seems odd no? I mean you explicitly defined it previously with the class wrapper, surely it should work?. Well.. that's true.. but you need one extra line:
Inserted just before you assign the variable myInstance into the main namespace.
The reason for this seemingly inexplicable behaviour comes from the Python documention:
int PyImport_AppendInittab (char *name, void (*initfunc)(void))
Add a single module to the existing table of built-in modules. This is a convenience wrapper around PyImport_ExtendInittab(), returning -1 if the table could not be extended. The new module can be imported by the name name, and uses the function initfunc as the initialization function called on the first attempted import. This should be called before Py_Initialize().
So, the code to register the convertor isn't called until the module is imported, and if you try to assign the variable directly to the dictionary it will fail until it IS imported.
Imagine your code looks something like this where you are tying to define a global variable that will be availiable to a python program. The global variable is actually an instance pointer to a C++ class.
BOOST_PYTHON_MODULE(TestModule)
{
class_("MyClass", no_init)
.def(self_ns::str(self))
;
};
PyImport_AppendInittab( "TestModule", initTestModule );
Py_Initialize();
MyClass *myInstance = new MyClass();
object main_module((handle<>(borrowed(PyImport_AddModule("__main__")))));
object main_namespace((main_module.attr("__dict__")));
main_namespace["myInstance"] = myInstance;
object ignored = exec_file("test.py", main_namespace, main_namespace);
Now, whenever you try to run it, you get an error:
TypeError: No to_python (by-value) converter found for C++ type: class MyClass
The culprit is the statement main_namespace["myInstance"] = myInstance;. Basically it's saying there is no convertor. Seems odd no? I mean you explicitly defined it previously with the class wrapper, surely it should work?. Well.. that's true.. but you need one extra line:
exec("import TestModule", main_namespace, main_namespace);
Inserted just before you assign the variable myInstance into the main namespace.
The reason for this seemingly inexplicable behaviour comes from the Python documention:
int PyImport_AppendInittab (char *name, void (*initfunc)(void))
Add a single module to the existing table of built-in modules. This is a convenience wrapper around PyImport_ExtendInittab(), returning -1 if the table could not be extended. The new module can be imported by the name name, and uses the function initfunc as the initialization function called on the first attempted import. This should be called before Py_Initialize().
So, the code to register the convertor isn't called until the module is imported, and if you try to assign the variable directly to the dictionary it will fail until it IS imported.
Friday, December 5, 2008
8,171 years should be enough for anybody
Came across this KB article: http://support.microsoft.com/kb/138365
"If you configure the Autodisconnect option to -1 at the command prompt, Autodisconnect is set to the upper value in the registry. This is approximately 8,171 years (not tested), which should be long enough to be the equivalent of turning Autodisconnect off."
"If you configure the Autodisconnect option to -1 at the command prompt, Autodisconnect is set to the upper value in the registry. This is approximately 8,171 years (not tested), which should be long enough to be the equivalent of turning Autodisconnect off."
Wednesday, November 19, 2008
Ah.. Java
I've been using Java for a few years now. And one thing that i've come across is.. memory leaks.
"Memory leaks?" you say. Yup. "In Java? That's unpossible!" you exclaim.
No really. It's true. The garbage collector makes a fine effort to clean up most unused objects, but every so often you'll get an object being stored that can't be collected because it's still referenced somewhere. Usually these are caused by putting a object into a static Map, or Array somewhere. Mostly it's the programmers fault, though the JRE/JDK itself may have some. This one for example is caused when you use a JPopup. A reference to the JComponent it is displayed on is kept internally by the standard Java libraries. If you only ever have one JPopup in your entire program, say in a startup page, and the rest of the program is all console based, then the reference to your window will be kept until the program exits. If your program is a daemon designed to run on a server, that could be a very very long time.
So.. how to find them? Well, luckily it's only a few step process.
Finding memory leaks using the Standard JDK 5.0 tools.
"Memory leaks?" you say. Yup. "In Java? That's unpossible!" you exclaim.
No really. It's true. The garbage collector makes a fine effort to clean up most unused objects, but every so often you'll get an object being stored that can't be collected because it's still referenced somewhere. Usually these are caused by putting a object into a static Map, or Array somewhere. Mostly it's the programmers fault, though the JRE/JDK itself may have some. This one for example is caused when you use a JPopup. A reference to the JComponent it is displayed on is kept internally by the standard Java libraries. If you only ever have one JPopup in your entire program, say in a startup page, and the rest of the program is all console based, then the reference to your window will be kept until the program exits. If your program is a daemon designed to run on a server, that could be a very very long time.
So.. how to find them? Well, luckily it's only a few step process.
Finding memory leaks using the Standard JDK 5.0 tools.
1. Run the program to check for leaks.
2. Try to do something that will expose the memory leak
3. Find the PID of the the java program by running jps.exe
4. Dump the memory of the program with this command
jmap -dump:format=b,file=heap.bin
5. Run jhat, it will start a webserver on the computer it's run on at port 7000
jhat -J-mx512m heap.bin
6. Load http://localhost:7000/ for general data
7. Load http://localhost:7000/histo/count and find the class you think is leaking, click on the link
8. Scroll down till you find the section called "Instances" and click "Include subclasses"
9. Find the instance that leaked and click it
10. Scroll down till you find the link "Exclude weak refs" and click it
11. A list of references will appear. Ignore any that contain a class called sun.awt.AppContext, or AppClassLoader as these classes are Java internal classes
12. The rest of the page will show which classes are still holding references to the object. Find out why it's holding it. Maybe you forgot to do a .remove() when the item was no longer needed.
And for my first trick!
A few phrases from a Markov text generator i wrote which can be surprisingly lucid at times. It uses text from the Gutenberg project, as well as a couple of Star trek scripts(Encounter at Farpoint)
"Seeming impossibly large, yet in some ways as delicate as a beardless youth, with hands of one"
"The Monkey King spread his wings and flowing drapery, which is evidently meant to reflect strength and power."
"From the time upon which he sowed as he feared a spark might get into the temple stood a vessel bound from Crete to the quick; and he was overcome with sorrow and indignation of his cheerless and unproductive portion of the day"
"Father," she said, "Follow me and end my wicked deeds"
"Priest of Unreason, and of Styx, the presiding nymph of Larissa, served as the Wicked Witch"
"Look out--here I go!" With skill will set the human intelligence. 42"
"Who's doing this? PICARD Get off my head, at last, he walked close to an energy beam, then back to Kansas"
"Noble Knights of Hunger."
"Men Erginus was so remote as {139} to be immolated on his hitherto luxurious couch, this also was painted green"
"Obeying his belly so that you can put your brains in your eagerness to please us."
"YOU AGREE THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF THE TURBOLIFT ENTRANCE"
"Besides, you have overlooked something--the mortality of the cow suddenly gave a distinct divinity, holding indisputable dominion over the entire bolt."
"Ready to beam up to Heaven's gate."
"Seeming impossibly large, yet in some ways as delicate as a beardless youth, with hands of one"
"The Monkey King spread his wings and flowing drapery, which is evidently meant to reflect strength and power."
"From the time upon which he sowed as he feared a spark might get into the temple stood a vessel bound from Crete to the quick; and he was overcome with sorrow and indignation of his cheerless and unproductive portion of the day"
"Father," she said, "Follow me and end my wicked deeds"
"Priest of Unreason, and of Styx, the presiding nymph of Larissa, served as the Wicked Witch"
"Look out--here I go!" With skill will set the human intelligence. 42"
"Who's doing this? PICARD Get off my head, at last, he walked close to an energy beam, then back to Kansas"
"Noble Knights of Hunger."
"Men Erginus was so remote as {139} to be immolated on his hitherto luxurious couch, this also was painted green"
"Obeying his belly so that you can put your brains in your eagerness to please us."
"YOU AGREE THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF THE TURBOLIFT ENTRANCE"
"Besides, you have overlooked something--the mortality of the cow suddenly gave a distinct divinity, holding indisputable dominion over the entire bolt."
"Ready to beam up to Heaven's gate."
Subscribe to:
Posts (Atom)