Function created in vala showing unexpected syntax error - vala

This is how I create a new function so that when a button is clicked, the preferences view should open.
But when I compile it, this is the error displayed.
https://github.com/Suzie97/epoch, link to the repository on github
What is the syntax error on my code?? Why is this error shown?

There's nothing wrong with your code snippet, but you have place it in your construct method of your class. In your Epoch.MainWindow calss in src/MainWindow.vala you want to method out of the scope of construct and in to the scope of MainWindow.

Related

In dart how to extend a custom PolymerElement with PaperInputBehavior?

Basically I try to do a port of GoldCcCvcInput to a dart implementation, instead of wrapping of a js implementation.
Looking at this:
https://github.com/PolymerElements/gold-cc-cvc-input/blob/master/gold-cc-cvc-input.html
Together with https://github.com/dart-lang/polymer-dart/wiki/behaviors
Something like:
#PolymerRegister('nbdate-input')
class NbdateInput extends PolymerElement with PaperInputBehavior,
IronControlState, IronA11yKeysBehavior ...
Minimal test project
https://github.com/jonboj/inputbehavior-dart.git
The project initialize without dumping any error messages and displays the iron-input elements ok. But when one of the iron-input elements are put in focus, the exception below is dumped in the console:
Uncaught TypeError: Cannot read property 'focus' of undefined
Polymer.PaperInputBehaviorImpl._onFocus
handler
Polymer.Base._addFeature.fire
Polymer.IronControlState._focusBlurHandler
This has an override of method onFocusedChanged https://github.com/PolymerElements/gold-cc-cvc-input/blob/master/gold-cc-cvc-input.html#L219
In dart a corresponding Observer is triggered, with a printout occurring after the exception dump.
https://github.com/jonboj/inputbehavior-dart/blob/master/lib/nbdatebehavior_input.dart#L56
I would check the console for errors, the mixin ordering doesn't look like it is correct and it should give you the desired ordering in a message, which may solve your issue (I would expect an ordering like this IronA11yKeysBehavior, IronControlState, PaperInputBehavior).
Additionally, make sure you are calling polymerCreated() in your constructor.
For my case the needed functionality was provided by
https://elements.polymer-project.org/elements/paper-input?active=paper-input-container
With Dart following the structure of last example (Social Security Number) in
https://elements.polymer-project.org/elements/paper-input?view=demo:demo/index.html&active=paper-input

Swift function call from class

So I have a class called Routes in which I have a function called getRouteInfo() that takes no parameters and has no return value and it is inside a Cocoa Touch class file. Then I have a tableView controller in which I want to call this function inside the viewDidLoad() method. For some reason, the compiler is forcing me to pass a parameter into it of type Routes even though my function is meant to not take any parameters.
The compiler is forcing me to pass a parameter inside the function :
Now, when I tried passing nil to it, I get the following error message: Nil is not compatible with expected argument type Routes.
Then when I try simply calling it as Routes.getRouteInfo() the compiler yells at me with: Missing argument for parameter #1 in call
If anybody could tell me why this is happening and how to resolve it, I'll be extremely grateful.

How can I stop Vaadin from triggering my window's ParameterHandler more than necessary?

I added a ParameterHandler to my application's main window so I can catch and process custom get parameters in my url. However, the presence of one parameter reloads the first page of my application, for some reason building this page triggers the handleParameters method again, this time with no parameters passed. If left unchecked (e.g. no ifs) the page's elements will just replicate themselves on top of themselves over and over again.
I suspect it has something to do with my main windows's addComponent method.
How can I stop it from doing that?
I completely forgot I still had this question open. I found that the problem was that the method got triggered for both get and post type parameters, and this is what caused the unexpected output.
I already implemented an HttpServletRequestListener because I used Vaadin's ThreadLocal pattern, so I just filtered all GET parameters out of the request object in one of the implemented methods and went from there.
debug your application and have a view at the call stack of the handleParameters method

What does a EClassNotFound raised at runtime really mean when the class in question is there at compile and link time, and there explicitly in code?

I have a runtime error happening in the rtl Streaming in of a form, causing an exception EClassNotFound to be raised, while doing TReader.ReadRootComponent. The particular error message is "Class not found TActionList".
What is odd is:
My main form uses Action list.
For fun, I added ActnList.pas (from the VCL source folder) to my project, to try to fix it.
This happens to me when instantiating a form that I had working until a few minutes ago. The change that I made was in some sub-frame code: I removed all its implementation section code with an ifdef marker, because I am mocking up some frames, for unit testing and prototypes.
I tried adding the action list class to the project, and I tried with and without various compiler and link options, and yet, I still get this exception. Obviously something weird is up. There must be another weird way to get this problem.
In fact, it seems there is something really weird going on. When this error is raised, I get the following call stack:
rtl.Classes.ClassNotFound('TActionList')
rtl.Classes.TReader.FindComponentClass(???)
rtl.Classes.FindExistingComponent
rtl.Classes.TReader.ReadComponent(nil) /// NIL!? WHAT!!!!!
rtl.Classes.TReader.ReadDataInner(???)
rtl.Classes.TReader.ReadData(???)
rtl.Classes.TComponent.ReadState(???)
vcl.Controls.TControl.ReadState(???)
vcl.Controls.TWinControl.ReadState($60B9CF0)
vcl.Forms.TCustomForm.ReadState(???)
rtl.Classes.TReader.ReadRootComponent($606EB90)
rtl.Classes.TStream.ReadComponent($606EB90)
rtl.Classes.InternalReadComponentRes(???,???,$606EB90)
rtl.Classes.InitComponent(TComplexFormContainingFrames)
It seems the nil is intentional, in TReader.ReadDataInner(Instance:TComponent):
while not EndOfList do ReadComponent(nil);
Update: I believe the answer to this question is to understand "serialization contexts" as Mason has mentioned. And, it's time to admit my own Stupidity: I removed the parent of the frame from the project, not realizing it was the parent of the frame. I worked around it being missing by stubbing the type declaration for TMyFrameParent as TMyFrameParent = class(TFrame), and this in turn lead to the condition in question. I am leaving the question here because I think it might be really handy in future to note when this exception occurs in arcane cases, and how to fix it. In particular, Mason has a really interesting bit of information about "serialization contexts" and how they apply to class-name-finding.
It means that the class wasn't found in the current deserialization context. Not all existing classes are registered for all loading. Each form class has RTTI containing references to the components it uses. To get this to work, make sure that your form (or frame, if this is a frame) declares at least one TActionList before the private tag:
TMyForm = class(TForm)
ActionList: TActionList;
OtherComponent: TSomeComponent;
private
//whatever
public
//whatever
end;
Use Classes.RegisterClass to register classes you want to use with the streaming system. Quote from the doc
Form classes and component classes that are referenced in a form declaration (instance variables) are automatically registered. Any other classes used by an application must be explicitly registered by calling RegisterClass if instances are to be saved. Once classes are registered, they can be loaded or saved by the component streaming system.
It seems that this happens when you copy a frame from one project to another project, and that frame inherits from something, and you fake the inheritance, but leave the "inherited" item descriptions in the frame dfm, items like this:
inherited ActionList: TActionList
Left = 520
Top = 576
end
This in turn results in the "current deserialization context" that Mason talked about, not containing the class. One fix is to change Inherited to object in all the above cases.
There is another way to get this error: put 'public' at the top of a form definition class. By default class members are 'published'. I accidentally added 'public' to the top of a form declaration and it produces multiple 'Class not found' exceptions at run-time.
I got a "EClassNotFound" error when I had a TLabel declaration present in my DFM file but there was no declaration for it in the corresponding PAS file. Somehow the form editor screwed up.
The error was not visible until I deleted all labels from my form except that particular "corrupted" one. It was difficult to hunt it down because that label was hidden under a panel.
One easy fix is to cut (ctrl+x) that label (once you find it) from the form and paste it back. This time the form editor will correctly insert a declaration for it in the PAS file.
There is yet another way to get this error: I have put 'private' at the top of a form definition class (because none of the elements were used outside the form).
So same like in previous answer (by Server Overflow): by default class members are 'published' and if you change visibility of a form declaration it produces multiple 'Class not found' exceptions at run-time.

Receiving invalid property value

It was only recently that I started receiving this error.
I am receiving a run time error that first says 'Invalid Property Value', I click continue and then receive another one saying "Error reading Image2.OnClick : Invalid Property Value".
I use Image2 to manoeuvre between different forms. I have tried deleting all components named "Image2" along with any code under the OnClick event, but still receive the error.
Any suggestions?
Somewhere in one of your .dfm files that contain the design time properties of your forms, you have an OnClick property that refers to a method that has either been removed, or is invalid in some other way.
Open the .dfm file for the offending form in a text edit, and look for Image2. You will then find the offending OnClick property setting and should be able to work out how best to resolve the problem.
It's probably related to your method's access level.
If your OnClick method is declared as either private or public, try changing its access level to Published or move it right below the form declaration line.

Resources