Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SFML 2.0 RC][Mac] http::sendRequest ends Application with crash.  (Read 2178 times)

0 Members and 1 Guest are viewing this topic.

Prox

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Hi,
I'm try to use sfml-network on Mac. Everything is compile fine and work ok until when i use method sendRequest, after this I have

sfmlNetwork(13838,0x7fff7de66960) malloc: *** error for object 0x7fff7e1e0860: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
(lldb)
 


Code:
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include "ResourcePath.hpp"
#include <iostream>

int main (int argc, const char * argv[])
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    // Load a sprite to display
    sf::Texture texture;
    if (!texture.loadFromFile(resourcePath() + "cute_image.jpg"))
        return EXIT_FAILURE;
    sf::Sprite sprite(texture);

    // Create a graphical text to display
    sf::Font font;
    if (!font.loadFromFile(resourcePath() + "sansation.ttf"))
        return EXIT_FAILURE;
    sf::Text text("Hello SFML", font, 50);
    text.setColor(sf::Color::Black);
   
    sf::Http http;
    http.setHost("http://s1t.ubergridgame.net");
   
    // Prepare a request to get the 'features.php' page
    sf::Http::Request request("index.php");
   
    // Send the request
   
    http.sendRequest(request);
    sf::Http::Response response;
   
    // Check the status code and display the result
    sf::Http::Response::Status status = response.getStatus();
    if (status == sf::Http::Response::Ok)
    {
        std::cout << response.getBody() << std::endl;
    }
    else
    {
        std::cout << "Error " << status << std::endl;
    }

    // Start the game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        while (window.pollEvent(event))
        {
                // Close window : exit
                if (event.type == sf::Event::Closed)
                        window.close();
           
                // Escape pressed : exit
                if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
                        window.close();
        }

        // Clear screen
        window.clear();
       
        // Draw the sprite
        window.draw(sprite);
       
        // Draw the string
        window.draw(text);

        // Update the window
        window.display();
    }

        return EXIT_SUCCESS;
}

 

Any tips for me ?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: [SFML 2.0 RC][Mac] http::sendRequest ends Application with crash.
« Reply #1 on: July 20, 2012, 12:42:21 pm »
You compiled SFML yourself, right ? Then you should have a look at this issue.
SFML / OS X developer

 

anything