I wrote most of a gui using clutter, using tons of global variables.
Clutter has a function which you use to connect an event or action like a mouse click to a function, and lets you pass one user data variable to it.
I wanted to eliminate globals. So I put everything in a struc to pass to each function, and after a few hours of doing all of this, I thought I almost got it working, but it's not the case.
I have this in the main
1 2
|
for (int i=0; i < 8; ++i )
clutter_actor_add_action(MV_CL_GUI.Actor_Wav[i], MV_CL_GUI.Wav_Action[i]);
|
which causes an error attempted to read or write protected memory.
When I comment that line out, the gui at least comes up, but as soon as a mouse event launches a function, the program crashes and gives a Debug Assertion Failed...click retry.
Then it points to a line in dbgdel.cpp
1 2 3 4 5
|
/* get a pointer to memory block header */
pHead = pHdr(pUserData);
/* verify block type */
_ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));
|
Here is what my struct looks like.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
struct Clutter_GUI{
string ProjectName;
ClutterActor *Actor_Enter_Source_Bar;
ClutterLayoutManager *Actor_Source_Directories_Box_Layout;
int Source_Row_Selected;
ClutterAction *Action_Track_Row_Rect[12];
ClutterAction *Action_Track_Scroll_Up;
int Track_Row_Selected;
ClutterVertex center_T;
ClutterAnimation *animation_W[9];
ClutterTimeline *TimeLine_T;
ClutterActor *Stage_MainMenu;
ClutterAction *Wav_Action[9];
ClutterActor *Actor_Wav[9];
ClutterActor *Actor_Notes_Text[18];
int Current_Notes_Text_Line;
gint Cursor_Position_Notes;
ClutterAction *Action_Run;
ClutterAction *Action_Settings;
ClutterActor *Actor_Run;
ClutterActor *Actor_Settings;
ClutterEffect * Effect_Desaturate_Run;
ClutterEffect * Effect_Desaturate_Settings;
ClutterTimeline *TimeLine_Run;
ClutterTimeline *TimeLine_Settings;
ClutterAnimation *animation_Run;
ClutterAnimation *animation_Settings;
guint8 Clear;
ClutterEffect * Effect_Desaturate_New_Project;
ClutterEffect * Effect_Desaturate_Load_Project;
gdouble Saturation;
gdouble NoSaturation;
bool NewProject_Selected;
bool LoadProject_Selected;
bool DeleteProject_Selected;
bool About_Selected;
};
|
Except it has about 5 times as many variables in it.
And I am accessing all of the members just using object dot member syntax.
here is an example of the functions used to connect functions to events or actions.
g_signal_connect ( MV_CL_GUI.Action_Root_Row_Rect[1], "clicked", G_CALLBACK (Root_Row_1_Clicked), &MV_CL_GUI);
The last parameter is the struct I am passing to the function.
and my functions look like this
void Root_Row_1_Clicked (Clutter_GUI_Object MV_CL_GUI) {...}
I am kind of confused about the correct way to do this, but the only way which seamed to work, on a very short test program, was this format. But my larger project is problematic.
Anyone have any ideas. Thanks