Strings owned by local stack objects can't be returned.
The BString is destroyed when the function returns and takes the storage pointed to by BString::String() with it, so returning such a pointer is bogus. Instead the return type is now a BString which takes over ownership of the string.
This commit is contained in:
@@ -713,7 +713,7 @@ ScreenshotWindow::_FindValidFileName(const char* name)
|
|||||||
if (orgPath == NULL)
|
if (orgPath == NULL)
|
||||||
return baseName;
|
return baseName;
|
||||||
|
|
||||||
fExtension = BString(fUtility.GetFileNameExtension(fImageFileType));
|
fExtension = fUtility.GetFileNameExtension(fImageFileType);
|
||||||
|
|
||||||
BPath outputPath = orgPath;
|
BPath outputPath = orgPath;
|
||||||
BString fileName;
|
BString fileName;
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ Utility::Save(BBitmap** screenshot, const char* fileName, uint32 imageType)
|
|||||||
if (nodeInfo.InitCheck() != B_OK)
|
if (nodeInfo.InitCheck() != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
nodeInfo.SetType(_GetMimeString(imageType));
|
nodeInfo.SetType(_GetMimeString(imageType).String());
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -187,10 +187,10 @@ Utility::MakeScreenshot(bool includeMouse, bool activeWindow,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
BString
|
||||||
Utility::GetFileNameExtension(uint32 imageType) const
|
Utility::GetFileNameExtension(uint32 imageType) const
|
||||||
{
|
{
|
||||||
BMimeType mimeType(_GetMimeString(imageType));
|
BMimeType mimeType(_GetMimeString(imageType).String());
|
||||||
BString extension("");
|
BString extension("");
|
||||||
|
|
||||||
BMessage message;
|
BMessage message;
|
||||||
@@ -203,11 +203,11 @@ Utility::GetFileNameExtension(uint32 imageType) const
|
|||||||
extension.SetTo("");
|
extension.SetTo("");
|
||||||
}
|
}
|
||||||
|
|
||||||
return extension.String();
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
BString
|
||||||
Utility::_GetMimeString(uint32 imageType) const
|
Utility::_GetMimeString(uint32 imageType) const
|
||||||
{
|
{
|
||||||
const char *dummy = "";
|
const char *dummy = "";
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <Point.h>
|
#include <Point.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
@@ -27,7 +28,7 @@ public:
|
|||||||
uint32 imageType) const;
|
uint32 imageType) const;
|
||||||
BBitmap* MakeScreenshot(bool includeCursor, bool activeWindow,
|
BBitmap* MakeScreenshot(bool includeCursor, bool activeWindow,
|
||||||
bool includeBorder) const;
|
bool includeBorder) const;
|
||||||
const char* GetFileNameExtension(uint32 imageType) const;
|
BString GetFileNameExtension(uint32 imageType) const;
|
||||||
|
|
||||||
BBitmap* wholeScreen;
|
BBitmap* wholeScreen;
|
||||||
BBitmap* cursorBitmap;
|
BBitmap* cursorBitmap;
|
||||||
@@ -42,7 +43,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void _MakeTabSpaceTransparent(BBitmap* screenshot,
|
void _MakeTabSpaceTransparent(BBitmap* screenshot,
|
||||||
BRect frame) const;
|
BRect frame) const;
|
||||||
const char* _GetMimeString(uint32 imageType) const;
|
BString _GetMimeString(uint32 imageType) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user