From: Milan B. <albis@EUnet.yu> - 2005-09-08 14:47:42
|
Nando Dessena wrote: > I have now committed a proof-of-concept macro-based implementation > (see other messages in this thread). The test case is the same, the > outcome should be the same; let me know. It works quite fine on GTK1 and GTK2. So, yes, we can go with this. Do you suggest that we enclose *every* event handler function in these? Also, I'm thinking how to get the most of it. For example we have those: Database *d = tree_ctrl->getSelectedDatabase(); if (!isValidDatabase()) return; We can change the getSelectedDatabase function to throw the exception. The code can be turned into two things, depending on whether the fact that database is not found is expected or not: 1. We expect to find the database, otherwise it is an error. We simply do: Database *d = tree_ctrl->getSelectedDatabase(); 2. We're just checking for database: Database *d; try { d = tree_ctrl->getSelectedDatabase(); } catch (const DatabaseNotSelectedException &e) { d = 0; } // rest of the function. Now, to avoid having code like that, I think we need two versions of getSelectedDatabase. One called "getSelectedDatabase" that throws the exception and other called "checkIfDatabaseSelected" that doesn't throw anything (works as the current getSelectedDatabase) function. The same would apply to getSelectedServer, getSelectedMetadataItem, etc. It would remove a lot of if() type of checks. What you guys think? -- Milan Babuskov http://www.flamerobin.org |