Chart.js custom plugin before destroy - chart.js

I have to manually destroy my chart instance by calling this.chart.destroy(); My problem is that I have a custom plugin which has event listeners. When a chart is destroyed, it notifies the plugins, and in the plugin's destroy call I call chart.canvas.removeEventListener(). But this works only for the automatic destroy, and when I call destroy manually, the canvas stops existing before the plugins are notified. As far as I could find, there are no events that are run before destroy, according to the documents stop and uninstall are also called after destroy.
Is there a way to have an event before destroying chart? Or is the only way to handle it to do it outside the plugin, for example uninstalling the plugin manually? If the latter, I think it is a bug.
Chart.js version: 3.5.1
Edit: doesn't work also for version 3.6.1.

I managed to make a workaround by placing the event listener removers to reset, and doing this.chart.notifyPlugins('reset') before this.chart.destroy(), so I can check if (chart.canvas) on plugin destroy. This is however just a workaround and I should not have to rely on manual removing, so I filed a bug ticket too.

Related

Windows Toast Notification callback not being invoked

I managed to send Toast messages but once clicked, the callback is not invoked. This is the toast-tutorial that was used.
The messages should be sent through classic Win32 and in order to do this, a shortcut needs to be created which contains the AUMID and the CLSID. This is explained in Step 5 of the tutorial, where for MSIX and WiX these id's are put in their config files. There isn't an explanation how to generate the shortcut in Win32, but can be found in another aumid-tutorial.
After following the steps provided, sending the toast works fine, but clicking it does not invoke the callback for handling the feedback.
One thing that stands out, is that the installShortcut function uses only the AUMID in the creation of the shortcut, the CLSID is only used when registering the COM Server, where the configuration for MSIX and WIX shortcuts use both.
It seems as there is the link missing that windows needs to route the feedback back into the app.
Toasts use the "ToastGeneric" binding.
Any idea why this is happening?
Just on the name alone it seems to me like you need to set the PKEY_AppUserModel_ToastActivatorCLSID property on the .lnk and not just the AUMID.
MSDN says:
Used to CoCreate an INotificationActivationCallback interface to notify about toast activations.
This page is marked as pre-release but does have a different InstallShortcut function that sets this property.
I have run the desktop-toasts sample successfully. As the code comment comments,
For the app to be activated from Action Center, it needs to provide a
COM server to be called when the notification is activated. The CLSID
of the object needs to be registered with the OS via its shortcut so
that it knows who to call later. The WiX installer adds that to the
shortcut. Be sure to install the app via the WiX installer once before
debugging!
If running the package project directly, It also works. The following picture shows What happens when I installed DesktopToastsCppWrlApp.msi generated by Wix Toolset.

CRichEditCtrl from resource loads 1.0 instead of 2.0

I'm trying to update my application to use RichEdit 2.0; it's been using 1.0 since forever. Per the Microsoft documentation, I've changed AfxInitRichEdit() to AfxInitRichEdit2(), and I changed the class in the resource file from RICHEDIT to RichEdit20A (which is correct for this application). There is only one richedit in the resource file.
The application fails when I try to do anything with the window that includes this richedit. The dialog creation fails somewhere inside of ::CreateDialogIndirect(), and although I put breakpoints in CRichEditCtrl::Create and also on the class I derive from it, those breakpoints do not trip.
Out of frustration I tried calling AfxInitRichEdit() again and also calling AfxInitRichEdit2(). The application works! The breakpoints I put in do trip--but only on controls I create dynamically, not the one from the resource file. And when I run Active Window Spy, I see that the richedit created from the resource file somehow has a class of RICHEDIT even though I explicitly said RichEdit20A, and yet the dynamic ones are RichEdit20A as intended.
_RICHEDIT_VER is 0x210, and I'm using Visual Studio 2013.
I just can't figure out why CreateDialogIndirect() is making a RICHEDIT control--or trying to make one and failing, if I don't call AfxInitRichEdit()--instead of a RichEdit20A in spite of explicit instructions to the contrary. Any ideas?
Well, I feel stupid. There's a script that runs as part of the build process to update some resources, and for some reason that script has sometimes gotten confused between the debug and release versions, and copied resources from the release build into the debug build. I don't know why that happens and it's an issue for another day, but the upshot is the .rc file I had changed was getting replaced with another one.
Building the release version with the changes, and then building the debug version again, solved the problem.

ListView in android for dynamic data

how to refresh List View dynamic data content in android?
I tried loading dynamic data for the List View in android application but no luck .Any advice how to accomplish this?
Call notifyDataSetChanged() on your Adapter object once you've modified the data in that adapter.
Some additional specifics on how/when to call notifyDataSetChanged() can be viewed in this Google I/O video.
Or else Look at this link.it may helpful.
Dynamic ListView in Android app
Or else
The right thing to do is to call notifyDataSetChanged() on your Adapter.
Troubleshooting
If calling notifyDataSetChanged() doesn't work all the layout methods won't help either. Believe me the list view was properly updated. If you fail to find the difference you need to check where the data in your adapter comes from.
If this is just a collection you're keeping in memory check that you actually deleted the item from the collection before calling the notifyDataSetChanged().
If you're working with a database or service backend you'll have to call the method to retrieve the information again (or manipulate the in memory data) before calling the notifyDataSetChanged().
The thing is this notifyDataSetChanged only works if the dataset has changed. So that is the place to look if you don't find changes coming through. Debug if needed.
UI Thread
It is true that this has to be called from the UI thread. Other answers have examples on how to achieve this. However this is only required if you're working on this information from outside the UI thread. That is from a service or a non UI thread. In simple cases you'll be updating your data from a button click or another activity/fragment. So still within the UI thread. No need to always pop that runOnUiTrhead in.
More Information
Another nice post about the power of list Views is found here:http://www.vogella.com/articles/AndroidListView/article.html

How to use TortoiseOverlays with my own handler

tortoiseSVN has a shell hook that add overlay icons on files.
They create a separate open source project to use it in their commons projects (tortoiseSvn,tortoiseGit,etc)
i've download the installer .msi from google code that install the hooker handler
i've got my own version of "IShellIconOverlayIdentifier::IsMemberOf" that use for the handlers
how i grab all together ?
Here is the only doc i found
Please note that the TortoiseOverlays handler does not reduce the work you have to do: you have to implement your own overlay handler and get it to work fully. Only then can you make use of the TortoiseOverlays handler if you still want to:
The purpose of the TortoiseOverlays handler is to share the handler slots the windows shell has (limited to 15). It's not to help you implement overlay handlers.
Once you have your own handler working, you can simply change the registry keys where you register your own handler. After that, TortoiseOverlays will be loading your overlay handler.

QDrag destroyed while dragging

I have a Windows/Linux Qt 4.3 application that uses drag and drop in a QTreeView. I have two very similar applications which use the same set of Qt libraries. Drag and drop works in both on Linux but in only in one on Windows.
In the application that does not work the QDrag object gets deleted as soon as the mouse is moved. It is deleted by a DeferredDelete event from the event queue which is still processed in Qt during a drag. I do not know how to see what is causing the QDrag object to get deleted prematurely.
I can not figure out a good way to debug this problem. I have compared the source and cannot find anything obvious. I have tried using the code from one of the applications in the other application.
Any suggestions?
Update:
The reason the QDrag operation failed is because COM was not initialized successfully so the call to DoDragDrop in QDrag::exec returned immediately. QApplication tried to initialize COM by calling OleInitialize in qt_init but it failed with the error "Cannot change thread mode after it is set".
The interesting thing is that this happens even when OleInitialize is the first thing done in main so the thread mode is getting set initially by some external dependency. One of the differences between the applications that work on Windows is that the one that fails also contains .NET code so maybe that is the problem.
Solved:
This problem is a COM/CLR interop issue. The CLR sets the apartment state to MTA when it initializes and then when Qt attempts to initialize COM it fails. This problem and an old solution are discussed by Adam Nathan in Gotcha with STAThreadAttribute and Managed C++. In Visual Studio 2005 you can set the /CLRTHREADATTRIBUTE:STA compiler option in Configuration Properties > Linker > Advanced to set the threading attribute to STA without needing to create a new entry point.
I have no idea what can cause this, but I would try to find out by subclassing QDrag, overwrite deleteLater() (well, reimplement it, but as it's a slot, it will get called anyway), use this instead of a QDrag and put a breakpoint in deleteLater().