Skip to content

Commit

Permalink
Merge pull request MoSync#318 from divineprog/ThreeTwo
Browse files Browse the repository at this point in the history
Fixed bug that causes Wormhole apps that are using WebAppMoblet to crash when using the File API.
  • Loading branch information
Anders Malm committed Dec 19, 2012
2 parents 3e7c1a4 + 50fedb6 commit c5c971a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
3 changes: 3 additions & 0 deletions libs/Wormhole/Libs/JSNativeUI/ResourceMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ namespace Wormhole
// A new instance of ImageDownloader is created.
mImageDownloader = new ImageDownloader();
mImageDownloader->addDownloadListener(this);

// Set default FileUtil object.
setFileUtil(new FileUtil());
}

/**
Expand Down
3 changes: 3 additions & 0 deletions libs/Wormhole/Libs/PhoneGap/PhoneGapMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ namespace Wormhole
{
mSensorEventToManager[i] = false;
}

// Set default FileUtil object.
setFileUtil(new FileUtil());
}

/**
Expand Down
30 changes: 27 additions & 3 deletions libs/Wormhole/MessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,33 @@ void MessageHandler::initialize(Wormhole::HybridMoblet* moblet)
mNativeUIMessageHandler = new NativeUIMessageHandler(webView);
mResourceMessageHandler = new ResourceMessageHandler(webView);

// Set the FileUtil object to use.
mPhoneGapMessageHandler->setFileUtil(moblet->getFileUtil());
mResourceMessageHandler->setFileUtil(moblet->getFileUtil());
// Set the FileUtil object to use...

// For the PhoneGapMessageHandler.
FileUtil* fileUtilPhoneGapHandler = mPhoneGapMessageHandler->getFileUtil();
if (fileUtilPhoneGapHandler != moblet->getFileUtil())
{
if (NULL != fileUtilPhoneGapHandler)
{
delete fileUtilPhoneGapHandler;
}
mPhoneGapMessageHandler->setFileUtil(moblet->getFileUtil());
}

// For the ResourceMessageHandler.
FileUtil* fileUtilResourceHandler = mResourceMessageHandler->getFileUtil();
if (fileUtilResourceHandler != moblet->getFileUtil())
{
if (NULL != fileUtilResourceHandler)
{
// Make sure it is not the same as the PhoneGapMessageHandler has.
if (fileUtilResourceHandler != fileUtilPhoneGapHandler)
{
delete fileUtilResourceHandler;
}
mResourceMessageHandler->setFileUtil(moblet->getFileUtil());
}
}
}

/**
Expand Down

0 comments on commit c5c971a

Please sign in to comment.