Jump to content
Developer Wiki and Function Reference Links ×

How to avoid crash when opening (and closing) a lot of files during a menu command


Nicolas Goutte

Recommended Posts

We are currently limited by the problem that during a menu command only a limited number of VW files can be opened, because, even if are closing them, they are not immediately closed, but only when the menu command is done.

 

Similarly, such an operation cannot be done either as a migration manager callback.

 

Does somebody knows a way to get around this?

Link to comment

The code we are trying is similar to this one.
(The crash comes in both cases, the #if 1 case (real documents) or the #else case (empty documents).
 

	using namespace VectorWorks::Filing;
#if 1
	// Opening real documents of Libraries\Default in the VW program folder

	IFolderIdentifierPtr libraryDefaultsIdentifiier(IID_FolderIdentifier);
	libraryDefaultsIdentifiier->Set(kDefaultsFolder, false);

	class Listener : public IFolderContentListener {
	public:
		EFolderContentListenerResult VCOM_CALLTYPE OnFolderContent(IFolderIdentifier* pFolderID) override
		{
			return eFolderContentListenerResult_Continue;
		}

		EFolderContentListenerResult VCOM_CALLTYPE OnFileContent(IFileIdentifier* pFileID) override
		{
			TXString path;
			pFileID->GetFileFullPath(path);
			if (path.ReverseFind(".vwx") >= 0)
				paths.Append(path);

			return eFolderContentListenerResult_Continue;
		}

		TXStringArray paths;
	};

	Listener listener;

	libraryDefaultsIdentifiier->EnumerateContents(&listener, true);


	for (const auto& path : listener.paths) {
		IFileIdentifierPtr pathFileIdentifier(IID_FileIdentifier);
		pathFileIdentifier->Set(path);
		gSDK->OpenDocumentPath(pathFileIdentifier, false);
		gSDK->CloseDocument();
	}

#else
	
	// Opening only empty documents
	for (int i = 0; i < 100; i++) {
		gSDK->OpenDocumentPath(nullptr, false);
		gSDK->CloseDocument();
	}

#endif

 

Edited by Nicolas Goutte
Link to comment

If I remember correctly, we had to add a Progress dialog for our bulk translation of files, otherwise VW crashed. But this issue was almost 10 years ago, not sure it's still an issue.

Also, I've found this in our code, it might be the fix to the same issue you are having?

 

	gSDK->CloseDocument();	
	gSDK->HandlePendingUpdatesAndActivates(); //workaround for bug in OnFileContent: to trigger closedocument

 

  • Like 3
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...