When using Texlipse together with Miktex 2.9 on my Windows machine, the system throws a NullPointerExcpetion each time the document is compiled.
The problem disappeared after I have updated the Miktex 2.9 distribution using the Update manager. Hope this helps others who have the same problem.
Regards,
Pwndrian
To me it happens too.
This is a workaround I did, however I think that it is not quite optimal solution.
I saw that there is a bug opened http://sourceforge.net/tracker/?func=detail&aid=3306779&group_id=133306&atid=726818.
There is the class net.sourceforge.texlipse.builder.TExlipseBuilder, I made the following changes to overcome this problem(Please note the differences in both functions). The problem is that in TExlipsePlugin in the function getCurrentProject the actEditor is null since there is no active editor when importing projects or when pressing on clean while no editor is open.
#Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
throws CoreException {
BuilderRegistry.clearConsole();
IWorkbenchPage page = TexlipsePlugin.getCurrentWorkbenchPage();
IEditorPart actEditor = null;
if (page.isEditorAreaVisible()
&& page.getActiveEditor() != null) {
actEditor = page.getActiveEditor();
}
if ( actEditor == null )
return null;
if (isUpToDate(getProject()))
return null;
Object s = TexlipseProperties.getProjectProperty(getProject(), TexlipseProperties.PARTIAL_BUILD_PROPERTY);
if (s != null) {
partialBuild(monitor);
} else {
buildFile(null, monitor);
}
return null;
}
/**
* Clean the temporary files.
*
* #see IncrementalProjectBuilder.clean
*/
#Override
protected void clean(IProgressMonitor monitor) throws CoreException {
IProject project = getProject();
BuilderRegistry.clearConsole();
IWorkbenchPage page = TexlipsePlugin.getCurrentWorkbenchPage();
IEditorPart actEditor = null;
if (page.isEditorAreaVisible()
&& page.getActiveEditor() != null) {
actEditor = page.getActiveEditor();
}
if ( actEditor == null )
return;
// reset session variables
TexlipseProperties.setSessionProperty(project, TexlipseProperties.SESSION_LATEX_RERUN, null);
TexlipseProperties.setSessionProperty(project, TexlipseProperties.SESSION_BIBTEX_RERUN, null);
TexlipseProperties.setSessionProperty(project, TexlipseProperties.BIBFILES_CHANGED, null);
// check main file
String mainFile = TexlipseProperties.getProjectProperty(project, TexlipseProperties.MAINFILE_PROPERTY);
if (mainFile == null || mainFile.length() == 0) {
// main tex file not set -> nothing builded -> nothing to clean
return;
}
cleanTempDir(monitor, project);
cleanOutput(monitor, project);
monitor.subTask(TexlipsePlugin.getResourceString("builderSubTaskCleanMarkers"));
this.deleteMarkers(project);
project.refreshLocal(IProject.DEPTH_INFINITE, monitor);
monitor.done();
}
Related
I'm new to Vala and linux programming in general.
Im am trying to enumerate the data similar to the 'stat' shell utility for a given folder.
So far it's this i got:
int main (string[] args) {
try {
File directory = File.new_for_path (".");
if (args.length > 1) {
directory = File.new_for_commandline_arg (args[1]);
}
FileEnumerator enumerator = directory.enumerate_children (FileAttribute.TIME_MODIFIED, 0);
FileInfo file_info;
while ((file_info = enumerator.next_file ()) != null) {
DateTime t = file_info.get_modification_date_time();
}
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
return 1;
}
return 0;
}
Console output:
vala --pkg gio-2.0 --pkg glib-2.0 main3.vala
main3.vala:16.24-16.59: error: The name `get_modification_date_time' does not exist in the context of `GLib.FileInfo?'
Could someone point me in the right direction?
Thanks.
The error is saying the method doesn't exist. Looking at Valadoc.org for get_modification_date_time it shows this was introduced in GLib version 2.62. That version was released 05 September 2019. It is likely your distribution doesn't include that release yet.
You can either try to update your version of GLib or use the now deprecated get_modification_time:
int main(string[] args) {
if (args[1] == null) {
stderr.printf("No filename given\n");
return 1;
}
var file = GLib.File.new_for_path (args[1]);
try {
GLib.FileInfo info = file.query_info("*", FileQueryInfoFlags.NONE);
print (info.get_modification_time().to_iso8601() + "\n");
print ("\n\nFull info:\n");
foreach (var item in info.list_attributes (null)) {
print( #"$item - $(info.get_attribute_as_string (item))\n" );
}
} catch (Error error) {
stderr.printf (#"$(error.message)\n");
return 1;
}
return 0;
}
It sometimes takes very long time to open connection to Redis. Looks like it depends on connecting thread's count and, maybe, PC configuration. I run test for 50 threads on two workstations with 4-core CPU's, and it takes 70-100ms to open connection, and on 8-core workstation and 8-core staging server it took 1000-1500ms and sometimes much more. Strange dependency, but it' reproductible.
When IIS application pool restarts, and all threads are trying to reconnect, it causes something like cache downtime. What I have to change to get reasonable connection time?
I use BookSleeve client, and here is code sample:
static void Main(string[] args)
{
for (var i = 0; i < threadCount; i++)
threads.Add(new Thread(RunThread));
foreach (var thread in threads)
thread.Start();
foreach (var thread in threads)
thread.Join();
}
static void RunThread()
{
var connection = TryGetConnection();
while (connection == null)
{
connection = TryGetConnection();
}
}
static RedisConnection TryGetConnection()
{
var connection = currentConnection;
if ((connection != null) && (connection.State == RedisConnectionBase.ConnectionState.Open))
return connection;
lock (syncRoot)
{
if ((currentConnection != null) && (currentConnection.State == RedisConnectionBase.ConnectionState.Open))
return currentConnection;
if ((connectionTask != null) && connectionTask.IsCompleted)
connectionTask = null;
if (connectionTask == null)
{
if ((currentConnection != null) && (currentConnection.State == RedisConnectionBase.ConnectionState.Closed))
{
currentConnection.Dispose();
currentConnection = null;
}
if (currentConnection == null)
{
currentConnection = new RedisConnection(
serverAddress,
serverPort,
ioTimeout: (int) operationTimeout.TotalMilliseconds,
syncTimeout: (int) operationTimeout.TotalMilliseconds);
}
if (currentConnection.State == RedisConnectionBase.ConnectionState.New)
currentConnection.Open();
}
}
return null;
}
Let's look; we have a loop here:
var connection = TryGetConnection();
while (connection == null)
{
connection = TryGetConnection();
}
it is not clear to me that TryGetConnection is correctly handling all scenarios ("opening", etc), but frankly, it is a moot point : if you are going to do a tight loop until you get a connection, you might as well simplify significantly. The first thing you could do would be to wait on the task (with a timeout, obviously), rather than using a hot loop. Generalizing:
var task = connection.Open();
connection.Wait(task);
The Wait in the above uses the connection's specified timeout, and does some work to simplify exceptions for you.
However, in this specific case, you could probably just use something like:
var connection = TryGetConnection();
// no loop here
with:
static RedisConnection TryGetConnection()
{
var connection = currentConnection;
if ((connection != null) && (connection.State == RedisConnectionBase.ConnectionState.Open))
return connection;
lock (syncRoot)
{ // double-checked
if ((connection != null) && (connection.State == RedisConnectionBase.ConnectionState.Open))
return connection;
connection = ConnectionUtils.Connect(config);
return connection;
}
}
where config is a composite of the values; basically something like:
myserver:6389,syncTimeout=1000
This configuration string can also be more complex, including multiple redis servers (master/slave etc), a service-name (for use with sentinel), a client-name (for use with client list), etc.
I suspect some of the complexity in your method is leading to some extra looping at the moment. See if it is any more reliable with the above.
below is the current codes i have.
what it does is basically loop thru project solution project file and detect if it is a C# file. however it can't detect files that are put in a folder , how can i modify it to read a C# file in a solution folder.
Regards , Andy
foreach (var projectItem in
_applicationObject.Solution.Projects.Cast<Project>().SelectMany(project => project.ProjectItems.Cast<ProjectItem>()))
{
//for (var i = 0; i < projectItem.FileCount; i++)
//{
if (projectItem.FileCount > 0 && projectItem.Name.EndsWith(".cs")) // check if project is .Cs files
{
string fileName;
try
{
fileName = projectItem.FileNames[0];
}
catch (Exception)
{
continue;
}
//end of find filename
}
}
This will print all items in the solution, I believe.
It works with C++ solution in VS 2012.
// XXX Test
IEnumerator enumerator = m_applicationObject.Solution.GetEnumerator();
string indent = " ";
while (enumerator.MoveNext())
{
Project p = enumerator.Current as Project;
if (p != null)
{
Debug.WriteLine(p.Name);
ProcessProjectItems(p.ProjectItems, indent);
}
}
// XXX Test
void ProcessProjectItems(ProjectItems pis, string indent)
{
if (pis == null)
return;
IEnumerator items = pis.GetEnumerator();
while (items.MoveNext())
{
ProjectItem pi = items.Current as ProjectItem;
if (pi != null)
{
Debug.WriteLine(indent + pi.Name);
if (pi.ProjectItems != null)
{
ProcessProjectItems(pi.ProjectItems, indent + " ");
}
else
{
Project p = pi.Object as Project;
if (p != null && p.ProjectItems != null)
ProcessProjectItems(p.ProjectItems, indent + " ");
}
}
}
}
I tried to listen file change event in BlackBerry base on FileExplorer example, but whenever I added or deleted file, it always showed "Deferring persistence as device is being used" and I can't catch anything .Here is my code:
public class FileChangeListenner implements FileSystemJournalListener{
private long _lastUSN; // = 0;
public void fileJournalChanged() {
long nextUSN = FileSystemJournal.getNextUSN();
String msg = null;
for (long lookUSN = nextUSN - 1; lookUSN >= _lastUSN && msg == null; --lookUSN)
{
FileSystemJournalEntry entry = FileSystemJournal.getEntry(lookUSN);
// We didn't find an entry
if (entry == null)
{
break;
}
// Check if this entry was added or deleted
String path = entry.getPath();
if (path != null)
{
switch (entry.getEvent())
{
case FileSystemJournalEntry.FILE_ADDED:
msg = "File was added.";
break;
case FileSystemJournalEntry.FILE_DELETED:
msg = "File was deleted.";
break;
}
}
}
_lastUSN = nextUSN;
if ( msg != null )
{
System.out.println(msg);
}
}
}
Here is the caller:
Thread t = new Thread(new Runnable() {
public void run() {
new FileChangeListenner();
try {
Thread.sleep(5000);
createFile();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
t.start();
Create file method worked fine:
private void createFile() {
try {
FileConnection fc = (FileConnection) Connector
.open("file:///SDCard/newfile.txt");
// If no exception is thrown, then the URI is valid, but the file
// may or may not exist.
if (!fc.exists()) {
fc.create(); // create the file if it doesn't exist
}
OutputStream outStream = fc.openOutputStream();
outStream.write("test content".getBytes());
outStream.close();
fc.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
and output:
0:00:44.475: Deferring persistence as device is being used.
0:00:46.475: AG,+CPT
0:00:46.477: AG,-CPT
0:00:54.476: VM:+GC(f)w=11
0:00:54.551: VM:-GCt=9,b=1,r=0,g=f,w=11,m=0
0:00:54.553: VM:QUOT t=1
0:00:54.554: VM:+CR
0:00:54.596: VM:-CR t=5
0:00:55.476: AM: Exit net_rim_bb_datatags(291)
0:00:55.478: Process net_rim_bb_datatags(291) cleanup started
0:00:55.479: VM:EVTOv=7680,w=20
0:00:55.480: Process net_rim_bb_datatags(291) cleanup done
0:00:55.481: 06/25 03:40:41.165 BBM FutureTask Execute: net.rim.device.apps.internal.qm.bbm.platform.BBMPlatformManagerImpl$3#d1e1ec79
0:00:55.487: 06/25 03:40:41.171 BBM FutureTask Finish : net.rim.device.apps.internal.qm.bbm.platform.BBMPlatformManagerImpl$3#d1e1ec79
I also tried to remove the thread or create or delete file in simulator 's sdcard directly but it doesn't help. Please tell me where is my problem. Thanks
You instantiate the FileChangeListenner, but you never register it, and also don't keep it as a variable anywhere. You probably need to add this call
FileChangeListenner listener = new FileChangeListenner();
UiApplication.getUiApplication().addFileSystemJournalListener(listener);
You also might need to keep a reference (listener) around for as long as you want to receive events. But maybe not (the addFileSystemJournalListener() call might do that). But, you at least need that call to addFileSystemJournalListener(), or you'll never get fileJournalChanged() called back.
Say I have an SVG element, as follows. How do I add an onClickListener?
solved, see below.
I'm going to guess you're meaning a FieldChangeListener rather than an OnClickListener (wrong platform ;). SVGImage isn't part of the RIM-developed objects, so unfortunately you won't be able to. Anything that is going to be able to have a FieldChangeListner has to be a subclass of the net.rim.device.api.ui.Field class.
Just in case someone's interested in how it's done...
try {
InputStream inputStream = getClass().getResourceAsStream("/svg/sphere1.svg");
_image = (SVGImage)SVGImage.createImage(inputStream, null);
_animator = SVGAnimator.createAnimator(_image, "net.rim.device.api.ui.Field");
_document = _image.getDocument();
_svg123 = (SVGElement)_document.getElementById("123");
}
catch (IOException e) { e.printStackTrace(); }
Field _svgField = (Field)_animator.getTargetComponent();
_svgField.setBackground(blackBackground);
add(_svgField);
_svg123.addEventListener("click", this, false);
_svg123.addEventListener("DOMFocusIn", this, false);
_svg123.addEventListener("DOMFocusOut", this, false);
}
public void handleEvent(Event evt) {
if( _svg123 == evt.getCurrentTarget() && evt.getType() == "click" ){ Dialog.alert("You clicked 123"); }
if( _svg123 == evt.getCurrentTarget() && evt.getType() == "DOMFocusIn" ) { ((SVGElement) _document.getElementById("outStroke123")).setTrait("fill", "#FF0000"); }
if( _svg123 == evt.getCurrentTarget() && evt.getType() == "DOMFocusOut" ) { ((SVGElement) _document.getElementById("outStroke123")).setTrait("fill", "#2F4F75"); }
}